Skip to content
BIASED

Calculate a discounted total

Structure check. The site checks the solution structure. Python is not executed.

price is the unit price, quantity is the number of items, and discount is a fraction from 0 to 1. For price = 1500, quantity = 2, discount = 0.2, the total is 2400.

Replace ... on the return line with an expression for the total. The def wrapper is provided: only an arithmetic expression is needed here; functions are covered later in the course. You can enter it on a phone without installing or running Python.

What is checked: expression structure and matching results on numerical substitutions. This is a static check of a restricted arithmetic expression, not execution of a Python program. Loops, input, imports and external libraries are not supported here. This optional exercise does not affect certificates.

Values, types and names