CSC111 Homework 11 2015
--D. Thiebaut (talk) 17:20, 12 April 2015 (EDT)
<showafterdate after="20150415 12:00" before="20150601 00:00">
This Homework is due on 4/21/15 at 11:55 p.m.
Contents
Problem #1: Temperatures in the UK
Assignment
- Your assignment is to write a program that reads weather data from a text file, then processes the data, and finally outputs the answers to several questions.
- Call your program hw11.py
The Text File
The Web site http://www.metoffice.gov.uk/climate/uk/stationdata/ keeps records of temperatures for 37 towns/cities of the UK for the past few years, going back in some cases to 1853.
Your assignment deals with data taken from this site. The different lists of temperatures have been stored on a local server at Smith College, and several are given to you to test your program on.
Background Information
- The main address for the data is that of the Met-Office site: http://www.metoffice.gov.uk/climate/uk/stationdata/
- The data has been replicated at http://cs.smith.edu/~dthiebaut/UKTemperatures/, and you can use this Smith-based Url instead. The data files are the same at both places.
- A file name is associated with each city or town. For example, the city of Aberporth is associated with aberporthdata.txt, and the record of the weather data for Aberporth is stored at URL http://cs.smith.edu/~dthiebaut/UKTemperatures/aberporthdata.txt
- The name of the file is simply the name of the town, all lowercase, followed by "data.txt."
Format of the data
- The format of the data is explained at http://www.metoffice.gov.uk/climate/uk/stationdata/, a copy of which is available here.
- Your program should accept estimated data as well as real data. In other words, data followed by an asterisk should not be dropped or skipped by your program.
Input
Your program should prompt the user for a file name. The user will supply the name of one of the text files that will have been previously downloaded from the Smith Web site listed above. In other words, your program simply needs to read a text file and does not need to access the Web.
Processing
- You must use the method illustrated in the first 2 problems of Lab 11 to process the data.
- All temperatures should be reported in degrees Celsius which is the system used in the U.K.
Questions
- Question 1
- In what year or years was the coldest temperature recorded? If the coldest temperature appears several times, list all the years and month in which it will have been reported.
- Question 2
- In what year or years was the warmest temperature recorded? If the warmest temperature appears several times, list all the years and month in which it will have been reported.
- Question 3
- What are the 5 sunniest months and years for the given city?
Output Format
- Here is the expected output for armaghdata.txt:
> armagh.txt Invalid file name, please re-enter > armaghdata.txt 1 -4.2 1878 12 1895 2 2 23.8 1995 8 1989 7 3 (256.0C) 1940 6 (252.9C) 1949 6 (251.6C) 1935 5 (244.1C) 1957 6 (243.8C) 1989 7
- and here is the expected output for ballpatrickdata.txt:
> ballypatrickdata.txt 1 -1.8 1979 1 2 20.0 1995 8 3 (279.3C) 1975 5 (272.6C) 1976 8 (253.7C) 1977 5 (247.2C) 1984 5 (245.6C) 1974 4
- Note that each line is prefixed with a number, identifying the question for which the line is the answer.
Moodle Submission
- Submit your program in the Moodle HW11 PB1 section.
</showafterdate>