Advertisement
Osiris1002

Computer Store

Feb 12th, 2024
1,215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. def calculate_taxes(price):
  2.     return price * 0.2
  3. def calculate_discount(total_price_with_taxes):
  4.     return total_price_with_taxes * 0.1
  5.  
  6. total_price_without_taxes = 0
  7.  
  8. while True:
  9.     price = input()
  10.     if price == "special" or price == "regular":
  11.         customer_type = price
  12.         break
  13.     price = float(price)
  14.     if price <= 0:
  15.         print("Invalid price!")
  16.         continue
  17.     total_price_without_taxes += price
  18.  
  19. if total_price_without_taxes == 0:
  20.     print("Invalid order!")
  21. else:
  22.     total_taxes = calculate_taxes(total_price_without_taxes)
  23.     total_price_with_taxes = total_price_without_taxes + total_taxes
  24.     if customer_type == "special":
  25.         discount = calculate_discount(total_price_with_taxes)
  26.         total_price_with_taxes -= discount
  27.     print("Congratulations you've just bought a new computer!")
  28.     print(f"Price without taxes: {total_price_without_taxes:.2f}$")
  29.     print(f"Taxes: {total_taxes:.2f}$")
  30.     print("-----------")
  31.     print(f"Total price: {total_price_with_taxes:.2f}$")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement