Advertisement
bl00dt3ars

06. Passengers Per Flight

Nov 14th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. import sys
  2. import math
  3.  
  4. companies = int(input())
  5. best_company = -sys.maxsize
  6. best_company_name = ""
  7.  
  8. for i in range(companies):
  9.     company = input()
  10.     command = input()
  11.     total_passengers = 0
  12.     flights = 0
  13.  
  14.     while command != "Finish":
  15.         passengers = int(command)
  16.         total_passengers += passengers
  17.         flights += 1
  18.  
  19.         command = input()
  20.         if command == "Finish":
  21.             if total_passengers / flights > best_company:
  22.                 best_company = math.floor(total_passengers / flights)
  23.                 best_company_name = company
  24.                 print(f"{company}: {math.floor(total_passengers / flights)} passengers.")
  25.             else:
  26.                 print(f"{company}: {math.floor(total_passengers / flights)} passengers.")
  27.  
  28. print(f"{best_company_name} has most passengers per flight: {best_company}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement