The request

From Angela Rivera, Head of Customer Support
Your goal
Fix the code so result is the order total (a float rounded to 2): the discounted subtotal plus shipping. Shipping is 0.0 for business accounts or when the discounted subtotal is $75 or more, otherwise 6.95.
- Store a number in
resultnot done yet
Your code
Loading the editor…
Reference solution
Mote checks your result
Press Run. Each row that matches the goal becomes a firefly in your lantern.
What Angela gets, and why
The lesson
Find the case that broke
Start from the complaint, not the code. The cart is 2 × $32.50 + $35.00 = $100.00, and a 25% coupon
leaves the customer paying 100 * (1 - 25 / 100), which is exactly 75.0. The promise on the site is
free shipping “from $75”, so this cart sits precisely on the boundary.
discounted = 100.0 * (1 - 25 / 100) # 75.0
discounted > 75 # False -> she pays 6.95
discounted >= 75 # True -> free shipping
> means strictly greater. When both sides are equal it is False, so the script fell through to
the else branch and charged $6.95. The total became $81.95 instead of $75.00.
Translate the words into the operator
Business rules use everyday words, and each one maps to a specific comparison:
- “from $75”, “$75 or more”, “at least $75”:
>= 75 - “over $75”, “more than $75”:
> 75 - “under $50”, “below $50”:
< 50 - “up to $50”, “$50 or less”:
<= 50
Before you write a condition, underline the words in the policy and pick the operator from that
list. Most boundary bugs come from writing > out of habit.
Test the edges
A good habit for any rule with a threshold is to try three values: one just below, one exactly on, and one just above. For this policy that means $74.99, $75.00 and $75.01. Only the first should pay shipping. The buggy script charges shipping on the first two, and you’d only catch it with the value exactly on the edge, which is why ordinary test carts didn’t reveal it.
Notice also that the check uses the discounted subtotal. The order of operations matters in the business sense too: the coupon comes off first, then the shipping rule looks at what is left.
Common mistakes
- Comparing the original subtotal ($100) with 75. That would give free shipping to a $90 cart with a 25% coupon, which only costs $67.50.
- Changing the threshold number instead of the operator, for example
> 74.99. - Rounding
discountedbefore the comparison and getting surprised by a float like 74.99999. Here the value is exactly 75.0, but if a calculation produces long decimals, round to cents first and then compare.
Lantern lit!
Practised: debuggingcomparisonboundariesif elif else
- Solved
- No hints
- First run
