...

/

Solution Review: Discounted Price

Solution Review: Discounted Price

Review the solution for the "Discounted Price" exercise.

We'll cover the following...

Solution

Let’s explore the solution to the problem of discounted price.

Press + to interact
price = 250
if price >= 300:
price *= 0.7 # (1 - 0.3)
elif price >= 200:
price *= 0.8 # (1 - 0.2)
elif price >= 100:
price *= 0.9 # (1 - 0.1)
elif price < 100 and price >= 0:
price *= 0.95 # (1 - 0.05)
print(price)

Explanation

Here’s a line-by-line explanation of the code that calculates the discounted price:

  • Line 1: Initializes ...