What’s the largest pollution values?

This section uses the same data file that we have been using, but if you want to see all of the data click on the Show button below. Once it appears, you can hide it again by clicking on the Hide button.

Before you keep reading...

Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

One of the interesting questions to explore is, “Which city has the worst pollution?” The program below figures that out for the PM 2.5 value. It will read all the data in, then set max25 (the maximum PM 2.5 value) to zero. It will then loop through all the city data and if the current pollution (in new25) is greater than max25, it will save that value in max25 and save that city name as maxCity. We need the float function to convert the string into a number that we can compare.

Replace the lines that start with a comment (a #) below to find the city with the highest PM 10 pollution. If you have trouble solving this, you can look at the other tab which shows a solution.

Change the lines that start with a comment (a #) below to find the city with the highest PM 10 pollution.

The following program prints the maximum PM 2.5 pollution found, but the code is mixed up. Drag the blocks of statements from the left column to the right column and put them in the right order. Then click on <i>Check Me</i> to see if you are right. You will be told if any of the lines are in the wrong order or have the wrong indention.

You have attempted 1 of 8 activities on this page