Advertisement
Spocoman

Energy Booster

Jan 5th, 2022
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.78 KB | None | 0 0
  1. fruit = input()
  2. size = input()
  3. volume = int(input())
  4. sum_fruit = 0
  5.  
  6. if fruit == "Watermelon":
  7.     if size == "small":
  8.         sum_fruit = 56 * 2
  9.     elif size == "big":
  10.         sum_fruit = 28.7 * 5
  11. elif fruit == "Mango":
  12.     if size == "small":
  13.         sum_fruit = 36.66 * 2
  14.     elif size == "big":
  15.         sum_fruit = 19.6 * 5
  16. elif fruit == "Pineapple":
  17.     if size == "small":
  18.         sum_fruit = 42.1 * 2
  19.     elif size == "big":
  20.         sum_fruit = 24.8 * 5
  21. elif fruit == "Raspberry":
  22.     if size == "small":
  23.         sum_fruit = 20 * 2
  24.     elif size == "big":
  25.         sum_fruit = 15.2 * 5
  26.  
  27. total = sum_fruit * volume
  28.  
  29. if 400 <= total <= 1000:
  30.     total *= 0.85
  31. elif total > 1000:
  32.     total /= 2
  33.  
  34. print(f'{total:.2f} lv.')
  35.  
  36.  
  37.  
  38. Решение с тернарен оператор:
  39.  
  40.  
  41. fruit = input()
  42. size = input()
  43. volume = int(input())
  44. sum_fruit = 0
  45.  
  46. if fruit == "Watermelon":
  47.     sum_fruit = 112 if size == "small" else 143.5
  48. elif fruit == "Mango":
  49.     sum_fruit = 73.32 if size == "small" else 98
  50. elif fruit == "Pineapple":
  51.     sum_fruit = 84.2 if size == "small" else 124
  52. elif fruit == "Raspberry":
  53.     sum_fruit = 40 if size == "small" else 76
  54.  
  55. total = sum_fruit * volume
  56.  
  57. if total >= 400:
  58.     if total <= 1000:
  59.         total *= 0.85
  60.     else:
  61.         total /= 2
  62.  
  63. print(f'{total:.2f} lv.')
  64.  
  65.  
  66. Фундаменталс решение:
  67.  
  68. fruit = input()
  69. size = input()
  70. volume = int(input())
  71.  
  72. price = {"Watermelon": {"small": 112, "big": 143.5},
  73.          "Pineapple": {"small": 84.2, "big": 124},
  74.          "Raspberry": {"small": 40, "big": 76},
  75.          "Mango": {"small": 73.32, "big": 98}}[fruit][size] * volume
  76.  
  77. price = {price < 400: price, 400 <= price <= 1000: price * 0.85, price > 1000: price / 2}
  78.  
  79. print(f'{price[True]:.2f} lv.')
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement