Due 10/28 at 11:59
Video games often track player scores. Given a list of scores, how do you find the best one? The worst one? The average? In this project you will write algorithms — step-by-step procedures — to analyze a list of numbers.
Your program must meet the following specifications:
for loop to look at every score in the listFor example, if your list is [85, 92, 78, 95, 88], your program should print something like:
High score: 95
Low score: 78
Average score: 87.6
To calculate the average, divide the total of all scores by how many scores are in the list:
average = total / len(scores)
A list stores multiple values in order. You can access items by index (starting at 0):
scores = [85, 92, 78, 95, 88]
print(scores[0]) # 85
print(scores[3]) # 95
print(len(scores)) # 5
A for loop lets you do something once for each item in a list:
scores = [85, 92, 78]
for score in scores:
print(score)
This prints each score on its own line.
Here is a starting point. Fill in the TODO comments to meet the specifications above!
# Create a list of scores
scores = [85, 92, 78, 95, 88]
# Start by assuming the first score is both the highest and lowest
highest = scores[0]
lowest = scores[0]
total = 0
# Loop through every score in the list
for score in scores:
# TODO: if this score is higher than highest, update highest
# TODO: if this score is lower than lowest, update lowest
# TODO: add this score to total
# Calculate the average
# TODO
# Print the results
# TODO
When you’re happy with your high score finder, download the .py file and submit it on Thinkwave.