Advertisement
bl00dt3ars

11. Clever Lily

Oct 25th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. age = int(input())
  2. machine_price = float(input())
  3. toy_price = int(input())
  4.  
  5. all_toys = 0
  6. money = 0
  7. given_money = 10
  8.  
  9. for i in range(1, age + 1):
  10.     if i % 2 == 1:
  11.         all_toys += 1
  12.     else:
  13.         money += given_money - 1
  14.         given_money += 10
  15.  
  16. money += all_toys * toy_price
  17.  
  18. if money >= machine_price:
  19.     left = money - machine_price
  20.     print(f"Yes! {left:.2f}")
  21. else:
  22.     money_needed = machine_price - money
  23.     print(f"No! {money_needed:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement