Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cargo_count = int(input())
- bus = 0
- truck = 0
- train = 0
- for i in range(cargo_count):
- cargo = float(input())
- if cargo < 4:
- bus += cargo
- elif cargo < 12:
- truck += cargo
- else:
- train += cargo
- total = bus + truck + train
- average = (bus * 200 + truck * 175 + train * 120) / total
- print(f'{average:.2f}')
- print(f'{bus / total * 100:.2f}%')
- print(f'{truck / total * 100:.2f}%')
- print(f'{train / total * 100:.2f}%')
- Тарикатско решение:
- cargo_count = int(input())
- bus = 0
- truck = 0
- train = 0
- for i in range(cargo_count):
- cargo = float(input())
- if cargo < 4:
- bus += cargo
- elif cargo < 12:
- truck += cargo
- else:
- train += cargo
- print(f'{(bus * 200 + truck * 175 + train * 120) / (bus + truck + train):.2f}')
- for i in [bus, truck, train]:
- print(f'{i / (bus + truck + train) * 100:.2f}%')
- Фундаменталс решение:
- cargo_count = int(input())
- total = {'bus': 0, 'truck': 0, 'train': 0}
- for i in range(0, cargo_count):
- cargo = float(input())
- total[{cargo >= 12: 'train', cargo < 12: 'truck', cargo < 4: 'bus'}[True]] += cargo
- average = (total['bus'] * 200 + total['truck'] * 175 + total['train'] * 120) / sum(total.values())
- print(f'{average:.2f}')
- for i in ['bus', 'truck', 'train']:
- print(f'{total[i] / sum(total.values()) * 100:.2f}%')
Add Comment
Please, Sign In to add comment