Advertisement
Spocoman

Excursion Calculator

May 28th, 2022
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1. people = int(input())
  2. season = input()
  3. price = 0
  4.  
  5. if season == 'spring':
  6.     if people <= 5:
  7.         price = 50
  8.     else:
  9.         price = 48
  10. elif season == 'summer':
  11.     if people <= 5:
  12.         price = 48.50
  13.     else:
  14.         price = 45
  15.  
  16. elif season == 'autumn':
  17.     if people <= 5:
  18.         price = 60
  19.     else:
  20.         price = 49.50
  21.  
  22. elif season == 'winter':
  23.     if people <= 5:
  24.         price = 86
  25.     else:
  26.         price = 85
  27.  
  28. if season == 'summer':
  29.     price *= 0.85
  30. elif season == 'winter':
  31.     price *= 1.08
  32.  
  33. sums = price * people
  34. print(f'{sums:.2f} leva.')
  35.  
  36.  
  37. РЕШЕНИЕ С IF И ТЕРНАРЕН ОПЕРАТОР:
  38.  
  39. people = int(input())
  40. season = input()
  41. price = 0
  42.  
  43. if season == 'spring':
  44.     price = 50 if people <= 5 else 48
  45. elif season == 'summer':
  46.     price = 48.50 if people <= 5 else 45
  47. elif season == 'autumn':
  48.     price = 60 if people <= 5 else 49.50
  49. elif season == 'winter':
  50.     price = 86 if people <= 5 else 85
  51.    
  52. price *= 0.85 if season == 'summer' else 1.08 if season == 'winter' else 1
  53.  
  54. sums = price * people
  55. print(f'{sums:.2f} leva.')
  56.  
  57.  
  58. РЕШЕНИЕ САМО С ТЕРНАРЕН ОПЕРАТОР:
  59.  
  60. people = int(input())
  61. season = input()
  62.  
  63. sums = (((50 if people <= 5 else 48) if season == 'spring' else
  64.         (48.50 if people <= 5 else 45) if season == 'summer' else
  65.         (60 if people <= 5 else 49.50) if season == 'autumn' else
  66.         (86 if people <= 5 else 85) if season == 'winter' else 0)
  67.         * ((0.85 if season == 'summer' else 1.08 if season == 'winter' else 1) * people))
  68.  
  69. print(f"{sums:.2f} leva.")
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement