24 lines
683 B
Python
24 lines
683 B
Python
#!/usr/bin/python3
|
|
# grades03
|
|
# List element manipulation.
|
|
|
|
numberOfScores = int(input("How many scores do you want to enter? "))
|
|
counter = 0 # Start counter at 0
|
|
scores = [] # Create an empty list
|
|
while(counter < numberOfScores):
|
|
nextScore = float(input("Enter the next value: "))
|
|
scores.append(nextScore)
|
|
counter += 1
|
|
|
|
# This is unnecessary and just here for debugging.
|
|
print(scores)
|
|
|
|
# We will sum the scores. Initialize sum value to zero then add each value to the sum.
|
|
|
|
sum = 0
|
|
for score in scores:
|
|
sum = sum + score
|
|
|
|
print(f"The sum of the {numberOfScores} scores is {sum:.2f}")
|
|
print(f"The average of the {numberOfScores} scores is {sum/numberOfScores:.2f}")
|