DiYane

Clever Lily 11/7

Aug 6th, 2021
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. age = int(input())
  2. price = float(input())
  3. toy_p = int(input())
  4.  
  5. money = 0  # holder when adding money from years
  6. toy_count = 0  # counter for toys, when not receiving money
  7. years = 0  # counter of even years
  8.  
  9. for i in range(1, age + 1):
  10.     if i % 2 == 0:
  11.         money += 10 + (toy_count - 1) * 10
  12.         years += 1
  13.     else:
  14.         toy_count += 1
  15.  
  16. collected_money = (money - years) + (toy_count * toy_p)
  17. if collected_money >= price:
  18.     print(f'Yes! {collected_money - price:.2f}')
  19. else:
  20.     print(f'No! {price - collected_money:.2f}')
Advertisement
Add Comment
Please, Sign In to add comment