Computer Science Homework

Please download
hw5_files.zip. and unzip it into the directory for your HW5. You will nd multiple data les
and a utility module, hw5util.py that will help with Part 1. We also provide you with a simple
test program hw5part1_test.py that demonstrates how to use the utility module to read in the
Part 1 data les.
The goal of this assignment is to work further with loops, lists and les. You are already familiar
with loops and lists. Files will be covered on Monday.
In Part 1 of the homework, you will use the utility module to read data from a le as shown in the
test program and you are required to use a double (i.e. nested) loop. In Part 2 of the homework,
you will need to read and process the data yourself, but cannot use a double loop. You may, of
course, use as many single loops as you like. Failure to follow these guidelines will lose you points.
Test your programs with smaller data les rst – use predictions_short.txt for Part 1 and
temp_data_short.txt for Part 2. This will allow you to more easily track if your programs are
working correctly or not before you try the full data sets les. In particular, the full temperature
le is quite large as you will nd out.
As always, make sure you follow the program structure guidelines. You will be graded on program
correctness as well as good program structure.
Remember as well that we will be continuing to test homeworks for similarity. So, follow our
guidelines for the acceptable levels of collaboration. You can download the guidelines from Piazza
in the resources section if you need a refresher.
Can you predict the future … of soccer?
Note that this part is intended as an exercise for double loops. You must use double loops for full
credit on this part!
A good friend of mine runs a soccer league before all major tournaments. Instructions for the
league are given at the end of this section for your entertainment. All participants have to guess all
games before the tournament starts and then when it ends, players are scored based on how well
they guessed. The scoring is simple:
Guessing the outcome of the game correctly (win/lose/draw) is 2 points.
Guessing the correct number of goals for either team is worth 1 point each.
The score for each player is the total score she gets for her guesses for all the games.
The player who has the highest score wins the league.

Your job in this homework is to ask the user for the name of a prediction le containing the guesses
by the league participants for a particular soccer tournament. Use the utility module we give
you to read the le and retrieve the data for the dierent players. As Dragnet would say, “The 

predictions you are about to read are real. The names have been changed to protect the innocent.”
(Are any of you familiar with Dragnet?) Your program will then:
Compute and print the scores for each player
Print the winner (or winners if there is a tie)
Compute and print the total score for each game across all the players
Print the hardest game or games to predict. This is the game or games with the lowest total
score.
Note that the rst two and the last two requests are almost identical, but iterate dierently.
Here is some more detail. The utility module we give you will read the prediction data into three
lists. For example, consider the following test program:

Leave a Reply

Your email address will not be published. Required fields are marked *