19.5. What’s the average pollution?

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.

This time, we would like to get the average pollution level. To do that, we need to take every PM2.5 value and add them all together. As we do this, we need to keep a count of how many values we have seen, so we can compute an average.

This program will calculate the average PM2.5 pollution level in the US data. Arrange the blocks in the right order and indent them correctly. You will use all of them.

Now let’s do the same thing for the PM10 values. This program is mostly done. There are a few lines that need to still be written, they are all marked with a TODO comment. Finish up the program so you can find the average PM10 level.

You have attempted of activities on this page