Untitled
unknown
plain_text
2 years ago
971 B
12
Indexable
# User input
number_of_cargo = int(input())
# Variables
price_accumulated = 0
sum_tonnage = 0
mini_bus_tonnage = 0
truck_tonnage = 0
train_tonnage = 0
# Logic
for i in range(number_of_cargo):
tonnage = int(input())
sum_tonnage += tonnage
if tonnage <= 3:
price_accumulated += 200*tonnage
mini_bus_tonnage += tonnage
elif tonnage <= 11:
price_accumulated += 175*tonnage
truck_tonnage += tonnage
else:
price_accumulated += 120*tonnage
train_tonnage += tonnage
# Calculations
average_price = price_accumulated/sum_tonnage
percentage_tonnage_minibus = (mini_bus_tonnage/sum_tonnage)*100
percentage_tonnage_truck = (truck_tonnage/sum_tonnage)*100
percentage_tonnage_train = (train_tonnage/sum_tonnage)*100
# Output
print(f"{average_price:.2f}")
print(f"{percentage_tonnage_minibus:.2f}%")
print(f"{percentage_tonnage_truck:.2f}%")
print(f"{percentage_tonnage_train:.2f}%")Editor is loading...
Leave a Comment