Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- season = input()
- km = float(input())
- sum = 0
- if 0 < km <= 5000:
- if season == 'Spring' or season == 'Autumn':
- sum = 0.75
- elif season == 'Summer':
- sum = 0.9
- else:
- sum = 1.05
- elif 5000 < km <= 10000:
- if season == 'Spring' or season == 'Autumn':
- sum = 0.95
- elif season == 'Summer':
- sum = 1.1
- else:
- sum = 1.25
- elif 10000 < km <= 20000:
- sum = 1.45
- print(f'{(sum * km * 4 * 0.9):.2f}')
- Решение с тернарен оператор:
- season = input()
- km = float(input())
- sum = 0
- if 0 < km <= 5000:
- sum = 0.75 if season == 'Spring' or season == 'Autumn' else 0.9 if season == 'Summer' else 1.05
- elif 5000 < km <= 10000:
- sum = 0.95 if season == 'Spring' or season == 'Autumn' else 1.1 if season == 'Summer' else 1.25
- elif 10000 < km <= 20000:
- sum = 1.45
- print(f'{(sum * km * 4 * 0.9):.2f}')
- Решение с колекция:
- season = input()
- km = float(input())
- budget = {0 < km <= 5000: {"Spring": 0.75, "Autumn": 0.75, "Summer": 0.9, "Winter": 1.05},
- 5000 < km <= 10000: {"Spring": 0.95, "Autumn": 0.95, "Summer": 1.1, "Winter": 1.25},
- km > 10000: {"Spring": 1.45, "Autumn": 1.45, "Summer": 1.45, "Winter": 1.45}}
- print(f"{(budget[True][season] * km * 4 * 0.9):.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement