Advertisement
DiYane

Computer store

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