Advertisement
Spocoman

04. Clever Lily

Dec 24th, 2021
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. age = int(input())
  2. machine = float(input())
  3. toy_price = float(input())
  4. total_sum = 0
  5. toy = 0
  6. birthday = 10
  7.  
  8. for i in range(1, age + 1):
  9.     if i % 2 == 0:
  10.         total_sum += birthday - 1
  11.         birthday += 10
  12.     else:
  13.         toy += 1
  14.  
  15. total_sum += toy * toy_price
  16.  
  17. if total_sum >= machine:
  18.     print(f'Yes! {total_sum - machine:.2f}')
  19. else:
  20.     print(f'No! {machine - total_sum:.2f}')
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement