You are on page 1of 3

COMP 115

Python Programming and Problem Solving FA 2021

Project 5: 2020 Tokyo Olympic Women’s 10m Platform Diving Finals

Total Points: 100 Points

Due: 11:59 PM, December 12th, 2021 (Sunday)

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)

Please enter the name of the file: scores.txt


----------------------------------------------------
Diver, Nation, Dive1, Dive2, Dive3, Dive4, Dive5
Alejandra Orozco, Mexico, 66.00, 57.60, 54.45, 75.20, 68.8
Andrea Spendolini-Sirieix, Great Britain, 58.50, 60.80, 63.00, 51.20, 72.00
Celine van Duijn, Netherlands, 50.40, 49.30, 60.80, 60.00, 67.20
Chen Yuxi, China, 82.50, 76.80, 85.80, 89.10, 91.20
Delaney Schnell, United States, 76.80, 65.60, 56.10, 79.50, 62.40
Elena Wassen, Germany, 67.20, 63.00, 60.90, 40.00, 60.80
Gabriela Agúndez, Mexico, 64.50, 70.95, 73.60, 74.25, 75.20
Lois Toulson, Great Britain, 63.00, 37.80, 62.40, 62.40, 64.00
Melissa Wu, Australia, 75.00, 76.80, 64.40, 73.60, 81.60
Pandelela Rinong, Malaysia, 18.00, 71.05, 60.80, 52.80, 43.20
Quan Hongchan, China, 82.50, 96.00, 95.70, 96.00, 96.00
Yulia Timoshinina, ROC, 46.50, 57.75, 44.80, 49.60, 64.35
----------------------------------------------------

1
*********** Congratulations! ************

Rank Medal Name Final Score


1 Gold Xxxx Xxxx xxx.xx
2 Silver Xxxx Xxxx xxx.xx
3 Bronze Xxxx Xxxx xxx.xx

To see the complete score sheet, please find it in final-scores.txt

Requirements & Grading


Your program should meet the following requirements.

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)

# Assignment: (Assignment Number):


# Author(s):
# Due Date: (Due Date)
#
# Description: write a small blurb about what this project's goals are
# and what tasks it accomplishes
# Comments: (Explain any known issues or questions if any)
# Honor Pledge: I have abided by the Wheaton Honor Code and
# all work below was performed by (Your Name).

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.

You might also like