Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- total_price_no_tax = 0
- total_price_with_tax = 0
- # Тук ти я изнесох променливата taxes за да може да не дава грешка в края кода
- taxes = 0
- while True:
- prices = input()
- # по условие са ти казали ако е special да вадиш 10%, а ти не го правеш, сега съм ти го написал правилно.
- if prices == "special":
- total_price_with_tax -= total_price_with_tax * 0.10
- break
- elif prices == "regular":
- break
- # По условие не правиш тази проверка за това дали цента е по-малка от 0-ла и
- # ако е трябва да спреш условията надолу да не се изпълнят, за това ползвам continue
- if float(prices) < 0:
- print("Invalid price!")
- continue
- total_price_no_tax += float(prices)
- # Това е начина който ти използваш за 20те процента
- # total_price_with_tax = (total_price_no_tax * 120) / 100
- # Това е моя начин да го намеря
- total_price_with_tax = (total_price_no_tax + (total_price_no_tax * 0.20))
- taxes = total_price_with_tax - total_price_no_tax
- # Това е друга проверка която не извършваш в кода ти, а именно - дали крайната сума е по-голяма от 0-ла
- if total_price_with_tax != 0:
- print("Congratulations you've just bought a new computer!")
- print(f"Price without taxes: {total_price_no_tax:.2f}$")
- print(f"Taxes: {taxes:.2f}$")
- print("-----------")
- print(f"Total price: {total_price_with_tax:.2f}$")
- else:
- print("Invalid order!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement