Advertisement
Spocoman

Mobile Operator

Feb 24th, 2022 (edited)
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.86 KB | None | 0 0
  1. year = input()
  2. type = input()
  3. net = input()
  4. month = int(input())
  5. price = 0
  6.  
  7. if type == "Small":
  8.     if year == "one":
  9.         price = 9.98
  10.     else:
  11.         price = 8.58
  12. elif type == "Middle":
  13.     if year == "one":
  14.         price = 18.99
  15.     else:
  16.         price = 17.09
  17. elif type == "Large":
  18.     if year == "one":
  19.         price = 25.98
  20.     else:
  21.         price = 23.59
  22. elif type == "ExtraLarge":
  23.     if year == "one":
  24.         price = 35.99
  25.     else:
  26.         price = 31.79
  27.  
  28. if net == "yes":
  29.     if price <= 10:
  30.         price += 5.50
  31.     elif 10 < price <= 30:
  32.         price += 4.35
  33.     else:
  34.         price += 3.85
  35.  
  36. total = price * month
  37.  
  38. if year == "two":
  39.     total -= 3.75 * total / 100
  40.  
  41. print(f"{total:.2f} lv.")
  42.  
  43. Решение с тернарен оператор:
  44.  
  45. year = input()
  46. type = input()
  47. net = input()
  48. months = int(input())
  49.  
  50. price = \
  51.     (9.98 if year == "one" else 8.58) if type == "Small" else \
  52.         (18.99 if year == "one" else 17.09) if type == "Middle" else \
  53.             (25.98 if year == "one" else 23.59) if type == "Large" else \
  54.                 (35.99 if year == "one" else 31.79) if type == "ExtraLarge" else 0
  55.  
  56. price += (5.50 if price <= 10 else 4.35 if 10 < price <= 30 else 3.85) if net == "yes" else 0
  57.  
  58. total = price * months * (0.9625 if year == "two" else 1)
  59.  
  60. print(f"{total:.2f} lv.")
  61.  
  62. Решение с колекция и тернарен оператор:
  63.  
  64. year = input()
  65. type = input()
  66. net = input()
  67. months = int(input())
  68.  
  69. price = {
  70.     "Small": {"one": 9.98, "two": 8.58},
  71.     "Middle": {"one": 18.99, "two": 17.09},
  72.     "Large": {"one": 25.98, "two": 23.59},
  73.     "ExtraLarge": {"one": 35.99, "two": 31.79}
  74. }[type][year]
  75.  
  76. total = (price + ((5.50 if sum <= 10 else 3.85 if price > 30 else 4.35) if net == "yes" else 0)) * months
  77.  
  78. print(f"{total * (0.9625 if year == 'two' else 1):.2f} lv.")
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement