Problem 174517 · easy · Level 01 Prerequisites & Setup

Checkout Discount Rules

conditionals · arithmetic · boolean flags

An online shop applies two discount rules at checkout. Write checkout_total(total, is_member):

  1. Orders of 200 or more get 20% off; orders of 100 or more (but under 200) get 10% off; smaller orders get no tier discount.
  2. Members then get a further 5% off the price left after step 1.

Return the final amount as a float rounded to 2 decimal places.

Examples

Input:  total = 250, is_member = False
Output: 200.0

Input:  total = 150, is_member = True
Output: 128.25
Explanation: 150 -> 135 after 10% off -> 128.25 after the member 5%.

Input:  total = 50, is_member = False
Output: 50.0

Constraints

  • 0 <= total <= 10**6
  • is_member is a boolean

Goals

  • Pick the single best tier discount
  • Stack a second discount on the already reduced price
  • Round money to two decimals
Starting Python…