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.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

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.

Post 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 59 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply