Spocoman

Santas Holiday

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