Editor

Bill With Sales Tax

#532 · Python Basics · Beginner · 30 XP · about 5 min

A stationery shop works out each bill in three steps:

  • The subtotal is price * quantity.
  • A customer who buys 10 or more of an item gets 10 percent off the subtotal.
  • Sales tax of tax_percent percent is then added to the subtotal, after any discount.

Write total_price(price, quantity, tax_percent) that returns what the customer pays, rounded to 2 decimal places with round(value, 2).

Examples

total_price(2.5, 4, 8)    # returns 10.8
total_price(2.5, 10, 8)   # returns 24.3
total_price(19.99, 1, 0)  # returns 19.99

In the second example the subtotal is 25.0, the discount brings it to 22.5, and 8 percent tax on top makes 24.3.

Note

quantity and tax_percent are whole numbers, 0 or more.

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.