Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fruit = input()
- day = input()
- quantity = float(input())
- price = 0
- if day == "Monday" or day == "Tuesday" or day == "Wednesday" or day == "Thursday" or day == "Friday":
- if fruit == "banana":
- price = 2.5
- elif fruit == "apple":
- price = 1.2
- elif fruit == "orange":
- price = 0.85
- elif fruit == "grapefruit":
- price = 1.45
- elif fruit == "kiwi":
- price = 2.7
- elif fruit == "pineapple":
- price = 5.5
- elif fruit == "grapes":
- price = 3.85
- elif day == "Saturday" or day == "Sunday":
- if fruit == "banana":
- price = 2.7
- elif fruit == "apple":
- price = 1.25
- elif fruit == "orange":
- price = 0.9
- elif fruit == "grapefruit":
- price = 1.6
- elif fruit == "kiwi":
- price = 3
- elif fruit == "pineapple":
- price = 5.6
- elif fruit == "grapes":
- price = 4.2
- if price > 0:
- print(f'{price * quantity:.2f}')
- else:
- print("error")
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- fruit = input()
- day = input()
- quantity = float(input())
- price = 0
- if day in ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday"):
- price = 2.5 if fruit == "banana" \
- else 1.2 if fruit == "apple" \
- else 0.85 if fruit == "orange" \
- else 1.45 if fruit == "grapefruit" \
- else 2.7 if fruit == "kiwi" \
- else 5.5 if fruit == "pineapple" \
- else 3.85 if fruit == "grapes" else 0
- elif day in ("Saturday", "Sunday"):
- price = 2.7 if fruit == "banana" \
- else 1.25 if fruit == "apple" \
- else 0.9 if fruit == "orange" \
- else 1.6 if fruit == "grapefruit" \
- else 3 if fruit == "kiwi" \
- else 5.6 if fruit == "pineapple" \
- else 4.2 if fruit == "grapes" else 0
- print(f'{price * quantity:.2f}' if price > 0 else 'error')
- РЕШЕНИЕ С КОЛЕКЦИЯ И ТЕРНАРЕН ОПЕРАТОР:
- fruit = input()
- day = input()
- quantity = float(input())
- workday_price = {'banana': 2.5, 'apple': 1.2, 'orange': 0.85, 'grapefruit': 1.45, 'kiwi': 2.7, 'pineapple': 5.5, 'grapes': 3.85}
- weekend_price = {'banana': 2.7, 'apple': 1.25, 'orange': 0.9, 'grapefruit': 1.6, 'kiwi': 3, 'pineapple': 5.6, 'grapes': 4.2}
- price = 0
- if day in ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday') and fruit in workday_price:
- price = workday_price[fruit]
- elif day in ('Saturday', 'Sunday') and fruit in weekend_price:
- price = weekend_price[fruit]
- print(f'{price * quantity:.2f}' if price > 0 else 'error')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement