Skip to content
Snippets Groups Projects
Commit 9b6c9768 authored by David Paul's avatar David Paul
Browse files

Update exercises to use correct test

parent 5a30c6c6
No related branches found
No related tags found
No related merge requests found
......@@ -110,7 +110,7 @@ exercises.append(exercise)
exercise = Exercise("Test-Driven Development")
exercise.instructions = "An online store requires a Python function to calculate the price of orders. The function should be called <code>calculate_price</code> and take the following two arguments (in order):<ul><li><code>price</code>: A dictionary mapping the name of each item sold by the store to the price of the item (in dollars)</li><li><code>order</code>: A dictionary mapping the name of each item a customer wishes to buy to the quantity of that item they wish to purchase</li></ul>The function should iterate over each item in the order and add the price to buy the desired quantity of that item to the total cost of the order. If any item in the order does not have a corresponding price, your function should raise a <code>KeyError</code>.<p>Once the cost of each item in the order has been calculated, the function should test to see if the overall cost for all items is greater than $100. If it is, a 10% discount should be applied to the overall cost. Otherwise, if the order is greater than $50, a 5% discount should be applied.</p><p>The overall cost of the order (after any applicable discounts) should then be returned by the function.</p><p>Write a function to meet these requirements.</p>"
exercise.code = "def calculate_price(price, order):\n\t# TODO: Implement this\n\tpass\n\nprice = {'book': 10.0, 'magazine': 5.5, 'newspaper': 2.0}\n\norder1 = {'book': 10}\norder2 = {'book': 1, 'magazine': 3}\norder3 = {'magazine': 5, 'book': 10}\n\nassert(95 == calculate_price(price, order1))\nassert(26.5 == calculate_price(price, order2))\nassert(114.75 == calculate_price(price, order3))\nprint(\"Done\")"
exercise.tests = [Test("Correct implementation", "Done")]
exercise.tests = [Test("Correct implementation", "Done\n")]
exercise.checks = [Check("Please don't alter the assertions", "assert\\(95 == calculate_price\\(price, order1\\)\\)"),
Check("Please don't alter the assertions", "assert\\(26.5 == calculate_price\\(price, order2\\)\\)"),
Check("Please don't alter the assertions", "assert\\(114.75 == calculate_price\\(price, order3\\)\\)"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment