CS 111: Introduction to Computer Science

Processing weather data

Hand in via Moodle as weather.py.

You may work alone or with a partner of your choosing on this assignment. Put your name and the name of you partner (if any) in the comment at the top of your source code. If you work with a partner, submit your code only once (i.e. to one partner's Moodle account, not to both).

Data and starter code

Goals

Summary

The website of the Minnesota Department of Natural Resources makes available daily weather data for the Minneapolis/St. Paul area (and other locations) collected since 1871. For this assignment, you're going to write functions to compute various statistics from this raw data, and a program to call the functions and generate a report.

The program: basic version

Your program, called weather.py, should produce a report looking something like the following. (The numbers I've included in this example are fictional—the correct answers will be something different.)

Highest temperature: 111.4 F (1927) Lowest temperature: -41.2 F (1986) Average high temperature: 58.3 F Average low temperature: 47.5 F Highest snowfall in a day: 37.4 inches (1990-11-01) Highest precipitation in a day: 17.5 inches (1943-05-02)

The program: the fancy version

Each of the statistics in the basic version of this assignment can be computed by performing a simple loop and storing only a small amount of intermediate data. For example, to compute the average high temperature over all the days in the dataset, you only need to keep track of the sum of the high temperatures and the number of days that have high temperatures listed.

Some statistics, however, require a little more sophisticated code. For example, to compute each year's total snowfall, you need to somehow keep a separate running total of snowfall for each year.

With that in mind, the basic version of the program described above will be worth 16 of 20 points, while the fancy version will add another 4 possible points to your total. That is, you have the potential to get a B (which is a good grade) by completing just the features described above. To get those extra 4 points, however, your program should produce a report like this:

Year Avg high Avg low Max temp Min temp Total Snowfall 1871 52.7 24.4 98.0 -21.0 47.4 1872 53.8 23.0 103.0 -12.0 50.1 ... 2018 57.2 25.9 98.0 -17.0 61.2 Highest temperature: 111.4 F (1927) Lowest temperature: -41.2 F (1986) Average high temperature: 58.3 F Average low temperature: 47.5 F Highest snowfall in a day: 37.4 inches (1990-11-01) Highest precipitation in a day: 17.5 inches (1943-05-02)

(Again, the numbers in this example are fictional.)

Notes and suggestions

Start early, ask questions, and have fun!