We appreciate your visit to Analyze Scores Write a program that reads an unspecified number of scores and determines how many scores are above or equal to the average and. This page offers clear insights and highlights the essential aspects of the topic. Our goal is to provide a helpful and engaging learning experience. Explore the content and find the answers you need!

(Analyze Scores)

Write a program that reads an unspecified number of scores and determines how many scores are above or equal to the average and how many scores are below the average. Enter a negative number to signify the end of the input. Assume that the maximum number of scores is 100.

Here is a sample run:

```
Enter a new score or negative number to exit: 99.1
Enter a new score or negative number to exit: 85.6
Enter a new score or negative number to exit: -1

Total scores entered: 2
Average score: 92.35
Number of scores above or equal to the average: 1
Number of scores below the average: 1
```

Answer :

Answer:

#section 1

ls = []

while True:

score = float(input('Enter a New score or negative number to exit: '))

if score < 0:

break

else:

ls.append(score)

#section 2

average = sum(ls)/len(ls)

a = [num for num in ls if num >= average]

print('Total Scores Entered: ',len(ls))

print('Average score entered is: ',average)

print('Number of scores above average is: ',len(a))

print('Number of scores below average is:', len(ls)-len(a))

Explanation:

The programming language used is python 3.

#section 1

In this section, an empty list is initialized to hold all the values that will be inputted.

A while loop created which prompts the user to enter an input until a negative value is entered. This while loop always evaluates to be true until a value less than 0 allows it to break.

Finally, all the scores are appended to the list.

#section 2

In this section the code gets the average by dividing the sum by the number of items in the list.

A new list 'a' is created to hold all the values that are greater than or equal to the average.

Finally, the results are printed to the screen.

I have attached an image with the example stated in your question.

Thanks for taking the time to read Analyze Scores Write a program that reads an unspecified number of scores and determines how many scores are above or equal to the average and. We hope the insights shared have been valuable and enhanced your understanding of the topic. Don�t hesitate to browse our website for more informative and engaging content!

Rewritten by : Barada

Final answer:

The question involves creating a program that calculates the average of an unspecified number of scores and counts how many scores are above, below, or equal to the average, ending input with a negative number. A Python code example demonstrates how to perform the calculations and output the results, using a list to store the scores and iteration to count the scores relative to the average.

Explanation:

To solve the problem of calculating the average score and determining the number of scores above, below, or equal to this average, we could start by defining a list to hold the scores and variables to keep track of the sum and count of scores. With each input we receive, we increment the sum and count, while also adding the score to the list if it's non-negative. When a negative number is entered, we mark the end of the input, calculate the average by dividing the total sum by the count of scores, and then iterate through the list to determine how many scores are above or equal to the average and how many are below it. Let's see a sample code written in Python that accomplishes this task:

# Initialize an empty list to store scores
scores = []
# Initialize sum and count of scores
total_sum = 0
count = 0
# Read scores from the user until a negative number is entered
while True:
score = float(input('Enter a new score or negative number to exit: '))
if score < 0:
break
scores.append(score)
total_sum += score
count += 1
# Calculate the average score
average_score = total_sum / count
# Initialize counters for scores above, equal to, and below average
above_or_equal_count = 0
below_count = 0
# Determine how many scores are above, equal to, or below the average
for score in scores:
if score >= average_score:
above_or_equal_count += 1
else:
below_count += 1
# Output the results
print(f'Total scores entered: {count}')
print(f'Average score: {average_score:.2f}')
print(f'Number of scores above or equal to the average: {above_or_equal_count}')
print(f'Number of scores below the average: {below_count}')

This program prompts the user for scores, calculates the average, and gives the count of scores in relation to the average.