Advertisement
Spocoman

04. Fishing Boat

Dec 21st, 2021 (edited)
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. budget = int(input())
  2. season = input()
  3. volume = int(input())
  4. price = 0
  5.  
  6. if season == 'Spring':
  7.     price = 3000
  8. elif season == 'Winter':
  9.     price = 2600
  10. else:
  11.     price = 4200
  12.  
  13. if volume <= 6:
  14.     price *= 0.9
  15. elif volume > 11:
  16.     price *= 0.75
  17. else:
  18.     price *= 0.85
  19.  
  20. if volume % 2 == 0 and season != 'Autumn':
  21.     price *= 0.95
  22.    
  23. budget -= price
  24.  
  25. if budget >= 0:
  26.     print(f'Yes! You have {budget:.2f} leva left.')
  27. else:
  28.     print(f'Not enough money! You need {abs(budget):.2f} leva.')
  29.  
  30.  
  31. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  32.  
  33. budget = int(input())
  34. season = input()
  35. volume = int(input())
  36.  
  37. price = 3000 if season == 'Spring' else 2600 if season == 'Winter' else 4200
  38. price *= 0.9 if volume <= 6 else 0.75 if volume > 11 else 0.85
  39. price *= 0.95 if volume % 2 == 0 and season != 'Autumn' else 1
  40. budget -= price
  41.  
  42. print(f'Yes! You have {budget:.2f} leva left.' if budget >= 0 else
  43.       f'Not enough money! You need {abs(budget):.2f} leva.')
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement