Professional Documents
Culture Documents
You will work on this project individually. Please keep the Academic
Integrity Policy in mind---do not share your code to anyone and do not
look at anyone else's code.
In this project, you will practice writing functions, loops, strings, lists, and
file input & output. In this project, you will develop a program to read the
score sheet of the 2020 Tokyo Olympic Women’s 10m Platform Diving
competition from an input file and compute the final scores. The outputs will
be written into an output file.
First, the program should ask the user to enter the name of an input file that
contains the score sheet. In this case, the input file is called scores.txt and
it stores the scores of 12 finalist (including a header row). See sample run
below for more details. Then, it reads the file to get the information on the
score sheet which includes the name and nation, and 5 dive scores for each
diver in the final competition. The program should print out the exact
contents of the file to the terminal. Third, compute the final score for each
diver by summing up all 5 diver scores. Then print out the information of the
top 3 divers based on the final score. Last, write the complete final score
sheet to an output file called final-scores.txt with the Name, Nation, and
Final Score of all 12 divers sorted by the Final Score in descending order.
Sample Run: (User inputs are shown in BOLD, place holders are shown in xxx)
1
*********** Congratulations! ************
1. Save your code in a file whose name consists of the first and last
names of all the members followed by p5. You should only submit one
file via onCourse. You do not need to include scores.txt and final-
scores.txt (5pts)
2. Include the basic header in your program as below. Follow the Code
Guidelines for variable/function names, indentation, commenting, and
code formatting. Include comments to explain your code when
necessary. (5 points)
3. Your program should first ask the user for the input filename. Then
read the score sheet in the file and print out the content including the
headers. (20pts)
4. You will need to use a list (or list of lists) to store the score sheet of all
divers. Then, sum up the five dive scores of each row to compute the
final score for each diver. Last, print out the Full Name, Nation, and
Final Score of the Gold medalist, Silver medalist, and the Bronze
medalist based on the final score (Top 3 only, highest to lowest) with
the appropriate headers. All columns should be left-aligned as shown
in the sample run except that the last column will be right-aligned.
(40pts)
5. In addition, write the complete final score sheet to an output file
named final-scores.txt with the Full Name, Nation, and Final
Score for each finalist sorted by the Final Score in descending order
2
similar to the sample run. The output should be nicely formatted with
Full name and Nation left aligned, and the Final Score right aligned.
(30pts)
Hint: how to sort a list of lists in python, you may want do some
research and try some examples first. Below is a good read for you to get
started.
https://www.delftstack.com/howto/python/sort-list-of-lists-in-python/
6. You are allowed to organize your code anyway you want but you need
to thoroughly test your program by checking the outputs and the
output file before you submit it.
7. All data should be directly read from the input file and stored in lists.
You should not hard-code the score sheet in your Python program.