Advertisement
Teo10

Untitled

Aug 26th, 2019
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. budget = float(input())
  2.  
  3. count = 0
  4. total = 0
  5. product_count = 0
  6. product_price = 0
  7. product_name = ""
  8.  
  9.  
  10. while budget > 0:
  11.     product_name = input()
  12.     if product_name == "Stop":
  13.         break
  14.     product_price = float(input())
  15.     if product_price > budget:
  16.         break
  17.  
  18.     count = count + 1
  19.     product_count = product_count + 1
  20.  
  21.     if count % 3 == 0:
  22.         product_price = product_price / 2
  23.  
  24.     budget = budget - product_price
  25.     total = total + product_price
  26.  
  27.  
  28.  
  29. if product_name == "Stop":
  30.     print(f"You bought {product_count} products for {total:.2f} leva.")
  31. elif product_price >= budget:
  32.     diff = product_price - budget
  33.     print("You don't have enough money!")
  34.     print(f"You need {abs(diff):.2f} leva!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement