Spocoman

Travel Agency

May 25th, 2022 (edited)
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.78 KB | None | 0 0
  1. town = input()
  2. pack = input()
  3. vip = input()
  4. days = int(input())
  5. if days > 7:
  6.     days -= 1
  7.  
  8. total = days
  9.  
  10. if (town in ("Bansko", "Borovets", "Varna", "Burgas") and
  11.         pack in ("noEquipment", "withEquipment", "noBreakfast", "withBreakfast")):
  12.     if days < 1:
  13.         print("Days must be positive number!")
  14.     else:
  15.         if town in ("Bansko", "Borovets"):
  16.             if pack == "withEquipment":
  17.                 total *= 100
  18.                 if vip == "yes":
  19.                     total *= 0.90
  20.             else:
  21.                 total *= 80
  22.                 if vip == "yes":
  23.                     total *= 0.95
  24.         else:
  25.             if pack == "withBreakfast":
  26.                 total *= 130
  27.                 if vip == "yes":
  28.                     total *= 0.88
  29.             else:
  30.                 total *= 100
  31.                 if vip == "yes":
  32.                     total *= 0.93
  33.  
  34.         print(f"The price is {total:.2f}lv! Have a nice time!")
  35.  
  36. else:
  37.     print("Invalid input!")
  38.  
  39.  
  40. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  41.  
  42. town = input()
  43. pack = input()
  44. vip = input()
  45. days = int(input())
  46. if days > 7:
  47.     days -= 1
  48.  
  49. total = days
  50.  
  51. if (town in ("Bansko", "Borovets", "Varna", "Burgas") and
  52.         pack in ("noEquipment", "withEquipment", "noBreakfast", "withBreakfast")):
  53.     if days < 1:
  54.         print("Days must be positive number!")
  55.     else:
  56.         if town in ("Bansko", "Borovets"):
  57.             total *= 100 * (0.90 if vip == "yes" else 1) if pack == "withEquipment" else 80 * (0.95 if vip == "yes" else 1)
  58.         else:
  59.             total *= 130 * (0.88 if vip == "yes" else 1) if pack == "withBreakfast" else 100 * (0.93 if vip == "yes" else 1)
  60.  
  61.         print(f"The price is {total:.2f}lv! Have a nice time!")
  62.  
  63. else:
  64.     print("Invalid input!")
  65.  
Add Comment
Please, Sign In to add comment