veronikaaa86

04. Clever Lily

Mar 20th, 2022 (edited)
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. age = int(input())
  2. price_wash_machine = float(input())
  3. toy_price = int(input())
  4.  
  5. money = 10
  6. sum = 0
  7. count_toys = 0
  8. brother = 0
  9. for i in range(1, age + 1):
  10.     if i % 2 != 0:
  11.         count_toys = count_toys + 1
  12.     else:
  13.         brother = brother + 1
  14.         sum = sum + money
  15.         money = money + 10
  16.  
  17. money_toys = count_toys * toy_price
  18. total_sum = money_toys + sum - brother
  19.  
  20. diff = abs(total_sum - price_wash_machine)
  21. if total_sum >= price_wash_machine:
  22.     print(f"Yes! {diff:.2f}")
  23. else:
  24.     print(f"No! {diff:.2f}")
Add Comment
Please, Sign In to add comment