Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calculate_taxes(price):
- return price * 0.2
- def calculate_discount(total_price_with_taxes):
- return total_price_with_taxes * 0.1
- total_price_without_taxes = 0
- while True:
- price = input()
- if price == "special" or price == "regular":
- customer_type = price
- break
- price = float(price)
- if price <= 0:
- print("Invalid price!")
- continue
- total_price_without_taxes += price
- if total_price_without_taxes == 0:
- print("Invalid order!")
- else:
- total_taxes = calculate_taxes(total_price_without_taxes)
- total_price_with_taxes = total_price_without_taxes + total_taxes
- if customer_type == "special":
- discount = calculate_discount(total_price_with_taxes)
- total_price_with_taxes -= discount
- print("Congratulations you've just bought a new computer!")
- print(f"Price without taxes: {total_price_without_taxes:.2f}$")
- print(f"Taxes: {total_taxes:.2f}$")
- print("-----------")
- print(f"Total price: {total_price_with_taxes:.2f}$")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement