Editor

Test a Discount Calculator

Write the tests · Intermediate · about 12 min

discounted_price(total) works out what a customer pays. Totals under 50 get no discount, totals from 50 up to but not including 100 get 10% off, and totals of 100 or more get 20% off. The result is rounded to 2 decimal places.

Write test_ functions with assert that pass on a correct version and fail on broken ones.

Examples

discounted_price(40)     # 40
discounted_price(60)     # 54.0
discounted_price(150)    # 120.0
def test_small_order():
assert discounted_price(40) == 40
The solution opens after your first Check.