Advertisement
Spocoman

01. Back To The Past

Dec 26th, 2021 (edited)
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. money = float(input())
  2. year = int(input())
  3. age = 18
  4.  
  5. for i in range(1800, year + 1):
  6.     if i % 2 == 0:
  7.         money -= 12000
  8.     else:
  9.         money -= 12000 + 50 * age
  10.     age += 1
  11.  
  12. if money < 0:
  13.     print(f'He will need {abs(money):.2f} dollars to survive.')
  14. else:
  15.     print(f'Yes! He will live a carefree life and will have {money:.2f} dollars left.')
  16.    
  17. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  18.  
  19. money = float(input())
  20. year = int(input())
  21. age = 18
  22.  
  23. for i in range(1800, year + 1):
  24.     money -= 12000 + (0 if i % 2 == 0 else 50 * age)
  25.     age += 1
  26.  
  27. print(f'He will need {abs(money):.2f} dollars to survive.' if money < 0 else
  28.       f'Yes! He will live a carefree life and will have {money:.2f} dollars left.')
  29.  
  30. ИЛИ ЛЕКО ТАРИКАТСКАТА:)
  31.  
  32. money = float(input())
  33. year = int(input()) - 1800
  34.  
  35. for i in range(year + 1):
  36.     money -= 12000 + (0 if i % 2 == 0 else 50 * (18 + i))
  37.  
  38. print(f'He will need {abs(money):.2f} dollars to survive.' if money < 0 else
  39.       f'Yes! He will live a carefree life and will have {money:.2f} dollars left.')
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement