Advertisement
Spocoman

09. Ski Trip

Dec 21st, 2021 (edited)
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.01 KB | None | 0 0
  1. night = int(input()) - 1
  2. room = input()
  3. rating = input()
  4.  
  5. total = 0
  6.  
  7. if room == "room for one person":
  8.     total = night * 18
  9. elif room == "apartment":
  10.     total = night * 25
  11.     if night < 10:
  12.         total *= 0.7
  13.     elif 10 <= night < 15:
  14.         total *= 0.65
  15.     else:
  16.         total *= 0.5
  17. elif room == "president apartment":
  18.     total = night * 35
  19.     if night < 10:
  20.         total *= 0.9
  21.     elif 10 <= night < 15:
  22.         total *= 0.85
  23.     else:
  24.         total *= 0.8
  25.  
  26. if rating == "positive":
  27.     total *= 1.25
  28. else:
  29.     total *= 0.9
  30.  
  31. print(f'{total:.2f}')
  32.  
  33. РЕШЕНИЕ С IF-ELSE И ТЕРНАРЕН ОПЕРАТОР:
  34.  
  35. night = int(input()) - 1
  36. room = input()
  37. rating = input()
  38.  
  39. total = 0
  40.  
  41. if room == "room for one person":
  42.     total = night * 18
  43. elif room == "apartment":
  44.     total = night * 25 * (0.7 if night < 10 else 0.65 if 10 <= night < 15 else 0.5)
  45. elif room == "president apartment":
  46.     total = night * 35 * (0.9 if night < 10 else 0.85 if 10 <= night < 15 else 0.8)
  47.  
  48. total *= 1.25 if rating == "positive" else 0.9
  49.  
  50. print(f'{total:.2f}')
  51.  
  52. РЕШЕНИЕ САМО С ТЕРНАРЕН ОПЕРАТОР:
  53.  
  54. night = int(input()) - 1
  55. room = input()
  56. rating = input()
  57.  
  58. total = night * (18 if room == "room for one person" else
  59.                  25 * (0.7 if night < 10 else 0.65 if 10 <= night < 15 else 0.5) if room == "apartment" else
  60.                  35 * (0.9 if night < 10 else 0.85 if 10 <= night < 15 else 0.8)) * (1.25 if rating == "positive" else 0.9)
  61.  
  62. print(f'{total:.2f}')
  63.  
  64. PЕШЕНИЕ С КОЛЕКЦИЯ И ТЕРНАРЕН ОПЕРАТОР:
  65.  
  66. night = int(input()) - 1
  67. room = input()
  68. rating = input()
  69.  
  70. total = night * {"room for one person": {night > 0: 18},
  71.                  "apartment": {night < 10: 25 * 0.7, 10 <= night < 15: 25 * 0.65, night >= 15: 25 / 2},
  72.                  "president apartment": {night < 10: 35 * 0.9, 10 <= night < 15: 35 * 0.85, night >= 15: 35 * 0.8}}[room][True]
  73.  
  74. total *= 1.25 if rating == "positive" else 0.9
  75.  
  76. print(f'{total:.2f}')
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement