Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- product = input()
- town = input()
- quantity = float(input())
- price = 0
- if town == "Sofia":
- if product == "coffee":
- price = 0.5
- elif product == "water":
- price = 0.8
- elif product == "beer":
- price = 1.2
- elif product == "sweets":
- price = 1.45
- elif product == "peanuts":
- price = 1.6
- elif town == "Plovdiv":
- if product == "coffee":
- price = 0.4
- elif product == "water":
- price = 0.7
- elif product == "beer":
- price = 1.15
- elif product == "sweets":
- price = 1.3
- elif product == "peanuts":
- price = 1.5
- elif town == "Varna":
- if product == "coffee":
- price = 0.45
- elif product == "water":
- price = 0.7
- elif product == "beer":
- price = 1.1
- elif product == "sweets":
- price = 1.35
- elif product == "peanuts":
- price = 1.55
- print(price * quantity)
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- product = input()
- town = input()
- quantity = float(input())
- price = (0.5 if town == 'Sofia' else 0.4 if town == 'Plovdiv' else 0.45 if town == 'Varna' else 0) if product == 'coffee' else \
- (0.8 if town == 'Sofia' else 0.7 if town == 'Plovdiv' else 0.7 if town == 'Varna' else 0) if product == 'water' else \
- (1.2 if town == 'Sofia' else 1.15 if town == 'Plovdiv' else 1.1 if town == 'Varna' else 0) if product == 'beer' else \
- (1.45 if town == 'Sofia' else 1.3 if town == 'Plovdiv' else 1.35 if town == 'Varna' else 0) if product == 'sweets' else \
- (1.6 if town == 'Sofia' else 1.5 if town == 'Plovdiv' else 1.55 if town == 'Varna' else 0) if product == 'peanuts' else 0
- print(price * quantity)
- РЕШЕНИЕ С РЕЧНИК:
- product = input()
- town = input()
- quantity = float(input())
- price = {'coffee': {'Sofia': 0.5, 'Plovdiv': 0.4, 'Varna': 0.45},
- 'water': {'Sofia': 0.8, 'Plovdiv': 0.7, 'Varna': 0.7},
- 'beer': {'Sofia': 1.2, 'Plovdiv': 1.15, 'Varna': 1.1},
- 'sweets': {'Sofia': 1.45, 'Plovdiv': 1.3, 'Varna': 1.35},
- 'peanuts': {'Sofia': 1.6, 'Plovdiv': 1.5, 'Varna': 1.55}
- }[product][town]
- print(price * quantity)
- Или тарикатската:)
- print({'coffee': {'Sofia': 0.5, 'Plovdiv': 0.4, 'Varna': 0.45}, 'water': {'Sofia': 0.8, 'Plovdiv': 0.7, 'Varna': 0.7},
- 'beer': {'Sofia': 1.2, 'Plovdiv': 1.15, 'Varna': 1.1}, 'sweets': {'Sofia': 1.45, 'Plovdiv': 1.3, 'Varna': 1.35},
- 'peanuts': {'Sofia': 1.6, 'Plovdiv': 1.5, 'Varna': 1.55}}[input()][input()] * float(input()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement