Advertisement
tod36

04. Tourist Shop from exam 05 2019

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