Page 1 of 1

Fix the 5 errors in the code below so that it runs and prints the largest PM 2.5 value and the city that has that value.

Posted: Fri May 20, 2022 5:24 pm
by answerhappygod
Fix the 5 errors in the code below so that it runs and prints
the largest PM 2.5 value and the city that has that value.
Fix The 5 Errors In The Code Below So That It Runs And Prints The Largest Pm 2 5 Value And The City That Has That Value 1
Fix The 5 Errors In The Code Below So That It Runs And Prints The Largest Pm 2 5 Value And The City That Has That Value 1 (39.94 KiB) Viewed 60 times
Save & Run Load History 1 inFile = open("uspoll.txt","r" 2 lines = inFile.readlines() 3 inFile.Close() 4 5 maxCity 6 max 25 = # initialize max25 7 for line lines: 8 values = line.split(":") 9 new25 = float(values[2]) # get the current value if new25 > max25 maxCity = values[0] max25 = new25 # save the new maximum 13 print("Largest PM 2.5 value is ", max25," in ", maxCity) 10 11 12 14