106k views
4 votes
Write a python application that allows a user to enter any number of student test scores until the user enters 999. If the score entered is less than 0 or more than 100, display an appropriate message and do not use the score. After all the scores have been entered, display the number of scores entered and the arithmetic average.

2 Answers

3 votes

Final answer:

The question requires creating a Python program to collect student test scores, filtering out invalid entries, and calculating the total number of scores and their average.

Step-by-step explanation:

The question involves writing a Python application which is clearly related to Computers and Technology. The application requires a user to input student test scores repeatedly until the sentinel value 999 is entered. The Python script must handle invalid input by displaying a message if the score is outside the acceptable range of 0 to 100 and it should not consider such scores in its calculations. Once all valid scores have been entered, the program should calculate and display the total number of scores received and their arithmetic average.

User Discolor
by
4.7k points
6 votes

Answer:

This program is as follows

total = 0; count = 0

testscore = int(input("Score: "))

while testscore != 999:

if testscore < 0 or testscore > 100:

print("Out of range")

else:

total+=testscore

count+=1

testscore= int(input("Score: "))

print(count,"scores entered")

print("Arithmetic Average:",total/count)

Step-by-step explanation:

This initializes total and count to 0

total = 0; count = 0

This gets input for score

testscore = int(input("Score: "))

The following iteration stop when 999 is entered

while testscore != 999:

This prints out of range for scores outside 0 - 100

if testscore < 0 or testscore > 100:

print("Out of range")

Otherwise

else:

The total score is calculated

total+=testscore

The number of score is calculated

count+=1

Get another input

testscore = int(input("Score: "))

The number of score is printed

print(count,"scores entered")

The average of score is printed

print("Arithmetic Average:",total/count)

User Hexabunny
by
4.8k points