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
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.
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
the largest PM 2.5 value and the city that has that value.
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