r/pythonhelp • u/alxsando177 • Feb 25 '22
python question
Write a Python program that stores player data in a dictionary.
The idea here is that the user will repeatedly enter a player name and a score. For each name, we maintain a list
of the scores that have been entered.
In a loop, ask the user for a name and then a numerical score, and then ask whether to do another. The prompt
asking for the score should ask for the first score if no score has been entered for that player yet and ask for
another score otherwise. In either case, the score prompt should mention the player by name. The user may
enter the same name more than one time. When a name is entered, check if the name is already in the
dictionary's keys. If it is not (if it's a new name), then add a new pair to the dictionary consisting of the name as
the key and the entered score inside a list as the value. If the name is already among the dictionary keys (the
name already has one or more scores stored for it), then append the current entered score to the end of the list
for that name.
After each score is recorded, ask the user whether to continue, accepting any answer starting with an upper-
case or lower-case Y to mean yes. When the user is done entering names and scores, create a sorted list of the
names. Then, using the sorted list, neatly print out each name and the average score for that player, along with
the best and worst scores for that player. The output should use a consistent numerical format for the average
score and right-justify each output line. See the sample run below for an adequate implementation.
I'm having trouble understanding this assignment, does anybody know what it is asking for and how I should format this?
1
u/Goobyalus Feb 25 '22
I'm having trouble understanding this assignment, does anybody know what it is asking for and how I should format this?
Looks like it's asking for you to record scores for people; and print average, best, and worst scores in exactly the format you posted in your comment here: https://www.reddit.com/r/pythonhelp/comments/t0rbrr/python_question/hybnnwd/
What exactly are you having trouble understanding?
1
u/alxsando177 Feb 25 '22
Enter a name: Charlotte
Enter the first score for Charlotte: 21
Enter more data (y/n) ? y
Enter a name: Joey
Enter the first score for Joey: 18
Enter more data (y/n) ? y
Enter a name: Joey
Enter another score for Joey: 17
Enter more data (y/n) ? YES
Enter a name: Joey
Enter another score for Joey: 19
Enter more data (y/n) ? yes
Enter a name: Anna
Enter the first score for Anna: 24
Enter more data (y/n) ? y
Enter a name: Anna
Enter another score for Anna: 26
Enter more data (y/n) ? Y
Enter a name: Charlotte
Enter another score for Charlotte: 23
Enter more data (y/n) ? y
Enter a name: Joey
Enter another score for Joey: 16
Enter more data (y/n) ? nO
Anna has average score 25.00 (best: 26, worst: 24)
Charlotte has average score 22.00 (best: 23, worst: 21)
Joey has average score 17.50 (best: 19, worst: 16)
This is what it wants me to print