Advertisement
veronikaaa86

04. Clever Lily

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