Skip to content
BIASED

A discount calculation function

Python in your browser. Run and check results on your device. No Python installation; results do not count towards course mastery.

Complete discounted_total(price, quantity, discount): return the purchase total after the discount. price is the unit price, quantity is the number of items, and discount is a fraction from 0 to 1.

Example: discounted_total(1500, 2, 0.2) returns 2400. No discount means the full total; a 100% discount means zero. Use return, not only print: the checker calls your function with different arguments. Intermediate variables and multiple lines are welcome.

Functions