Advertisement
PowerCell46

Clever Lily Python

Dec 17th, 2022
836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import math
  2.  
  3. age = int(input())
  4. washing_machine_price = float(input())
  5. price_for_a_toy = int(input())
  6. number_of_toys = 0
  7. colected_money = 0
  8. current_money = 0
  9. for current_age in range(1, age + 1):
  10.     if current_age % 2 != 0:
  11.         number_of_toys += 1
  12.     else:
  13.         current_money += 10
  14.         colected_money += current_money
  15.         colected_money -= 1
  16.  
  17. colected_money += (number_of_toys * price_for_a_toy)
  18.  
  19. if colected_money >= washing_machine_price:
  20.     left_money = math.fabs(colected_money - washing_machine_price)
  21.     print(f'Yes! {left_money:.2f}')
  22. else:
  23.     needed_money = math.fabs(washing_machine_price - colected_money)
  24.     print(f'No! {needed_money:.2f}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement