Sichanov

clever lily

May 1st, 2021
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. age = int(input())
  2. washing_machine_price = float(input())
  3. toy_price = int(input())
  4.  
  5. saved_money = 0
  6. money_per_birthday = 0
  7.  
  8. for year in range(1, age + 1):
  9.     if year % 2 != 0:
  10.         saved_money += toy_price
  11.     elif year % 2 == 0 and year == 2:
  12.         money_per_birthday = 10
  13.         saved_money += money_per_birthday
  14.     elif year % 2 == 0 and year != 2:
  15.         money_per_birthday += 10
  16.         saved_money += money_per_birthday
  17.  
  18. # Money for brother
  19. saved_money -= (age // 2)
  20.  
  21. diff = abs(saved_money - washing_machine_price)
  22.  
  23. if saved_money >= washing_machine_price:
  24.     print(f'Yes! {diff:.2f}')
  25. else:
  26.     print(f'No! {diff:.2f}')
Advertisement
Add Comment
Please, Sign In to add comment