Sichanov

logistics

May 26th, 2021
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. number_of_cargo = int(input())
  2. average_price = 0
  3. microbus = 0
  4. truck = 0
  5. train = 0
  6. total_weight = 0
  7. price = 0
  8. for cargo in range(number_of_cargo):
  9.     weight = int(input())
  10.     if weight <= 3:
  11.         microbus += weight
  12.         price += weight * 200
  13.     elif weight <= 11:
  14.         truck += weight
  15.         price += weight * 175
  16.     else:
  17.         train += weight
  18.         price += weight * 120
  19.     total_weight += weight
  20.  
  21. average_price = price / total_weight
  22. print(f'{average_price:.2f}')
  23. average_microbus = microbus / total_weight * 100
  24. print(f'{average_microbus:.2f}%')
  25. average_truck = truck / total_weight * 100
  26. print(f'{average_truck:.2f}%')
  27. average_train = train / total_weight * 100
  28. print(f'{average_train:.2f}%')
Advertisement
Add Comment
Please, Sign In to add comment