desislava_topuzakova

11. Clever Lily

Mar 1st, 2021
1,034
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. age = int(input())
  3. price_laundry = float(input())
  4. price_per_toy = int(input())
  5. # парите на Лили = играчки(бр. играчки * цена за 1 играчка) + спестени пари
  6. count_toys = 0
  7. saved_money = 0
  8.  
  9. # за всеки рожден ден от [1 до възрастта] -> проверяваме какво е получила
  10. for birthday in range(1, age + 1):
  11.     if birthday % 2 == 1:
  12.         count_toys += 1
  13.     else:
  14.         saved_money += birthday * 5 - 1
  15.  
  16. # броят на играчките
  17. # спестени пари
  18.  
  19. #парите на Лили
  20. total_money = saved_money + (count_toys * price_per_toy)
  21.  
  22. if total_money >= price_laundry:
  23.     left_money = total_money - price_laundry
  24.     print(f"Yes! {left_money:.2f}")
  25. else:
  26.     need_money = price_laundry - total_money
  27.     print(f"No! {need_money:.2f}")
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×