Advertisement
tod36

04. Tourist Shop from exam 05 2019

Feb 28th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. budget = float(input())
  2. command = ""
  3. product_name = ""
  4. product_price = 0
  5. numb_of_item = 0
  6. all_price = 0
  7. all_numb = 0
  8.  
  9.  
  10. while command != "Stop":
  11.     product_name = input()
  12.     if product_name == "Stop":
  13.         break
  14.     else:
  15.         pass
  16.     product_price = float(input())
  17.     numb_of_item += 1
  18.     if numb_of_item == 3:
  19.         product_price = product_price / 2
  20.     else:
  21.         pass
  22.     all_price += product_price
  23.     if (budget - all_price) < 0:
  24.         print(f"You don't have enough money!")
  25.         print(f"You need {abs(budget - all_price):.2f} leva!")
  26.         exit()
  27.     all_numb += 1
  28.     command = product_name
  29. print(f"You bought {all_numb} products for {all_price:.2f} leva.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement