Advertisement
Spocoman

Computer Room

Jun 25th, 2022 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. month = input()
  2. hours = int(input())
  3. people = int(input())
  4. time = input()
  5. price = 0
  6.  
  7. if month in ("march", "april", "may"):
  8.     if time == "day":
  9.         price = 10.5
  10.         hours = 3
  11.     else:
  12.         price = 8.4
  13.  
  14. elif month in ("june", "july", "august"):
  15.     if time == "day":
  16.         price = 12.6
  17.     else:
  18.         price = 10.2
  19.  
  20. if people >= 4:
  21.     price *= 0.9
  22.  
  23. if hours >= 5:
  24.     price /= 2
  25.  
  26. total = price * people * hours
  27.  
  28. print(f"Price per person for one hour: {price:.2f}")
  29. print(f"Total cost of the visit: {total:.2f}")
  30.  
  31.  
  32. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  33.  
  34. month = input()
  35. hours = int(input())
  36. people = int(input())
  37. time = input()
  38.  
  39. price = (10.5 if time == "day" else 8.4) if month in ("march", "april", "may") else \
  40.         (12.6 if time == "day" else 10.2) if month in ("june", "july", "august") else 0
  41.  
  42. hours = 3 if month in ("march", "april", "may") and time == "day" else hours
  43. price *= 0.9 if people >= 4 else 1
  44. price /= 2 if hours >= 5 else 1
  45. total = price * people * hours
  46.  
  47. print(f"Price per person for one hour: {price:.2f}\n"
  48.       f"Total cost of the visit: {total:.2f}")
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement