121k views
3 votes
Write an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than 0 or more than 10, display Score must be between 10 and 0 and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average.

1 Answer

6 votes

Answer:

scores = []

total = 0

count = 0

highest = 0

lowest = 10

while True:

score = int(input("Enter quiz score: "))

if score == 99:

break

if score < 0 or score > 10:

print("Score must be between 10 and 0")

else:

total += score

count += 1

scores.append(score)

if score > highest:

highest = score

if score < lowest:

lowest = score

average = total / count

print("Scores:")

for s in scores:

print(s, end=" ")

print()

print("The highest score is " + str(highest))

print("The lowest score is " + str(lowest))

print("The arithmetic average is " + str(average))

Step-by-step explanation:

*The code is in Python.

Initialize the values

Create an indefinite while loop. Inside the loop, ask the user to enter the quiz score. If the score is 99, stop the loop. If the score is smaller than 0 or greater than 10, warn the user. Otherwise, add the score to total, increment the count by 1, and add the score to the scores list. Then, determine the highest and lowest value using if statements.

After the loop, calculate the average.

Print the valid scores, highest score, lowest score and arithmetic average

User Drew Rush
by
6.3k points