Advertisement
veronikaaa86

04. Clever Lily

Oct 2nd, 2022
1,225
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. brother_count = 0
  6. count_toys = 0
  7. total_sum = 0
  8. money = 0
  9. for i in range(1, age + 1):
  10.     if i % 2 != 0:
  11.         count_toys = count_toys + 1
  12.     else:
  13.         brother_count += 1
  14.         money = money + 10
  15.         total_sum = total_sum + money
  16.  
  17. result = (count_toys * toy_price) + total_sum - brother_count
  18.  
  19. diff = abs(result - price_wash_machine)
  20. if result >= price_wash_machine:
  21.     print(f"Yes! {diff:.2f}")
  22. else:
  23.     print(f"No! {diff:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement