Ask the user to enter 10 test scores. Write a program to do the following: 

(a) Print out the highest and lowest scores. 

(b) Print out the average of the scores. 

(c) Print out the second largest score. 

(d) If any of the scores is greater than 100, then after all the scores have been entered, print
a message warning the user that a value over 100 has been entered. 

(e) Drop the two lowest scores and print out the average of the rest of the.


# initialize a list to store the test scores

test_scores = []


# loop 10 times to get the test scores from the user

for i in range(10):

  # get the test score from the user

  test_score = int(input("Enter a test score: "))

  # add the test score to the list

  test_scores.append(test_score)


# sort the test scores

test_scores.sort()


# print the highest and lowest scores

print(f"Highest score: {test_scores[-1]}")

print(f"Lowest score: {test_scores[0]}")


# compute the average of the test scores

average = sum(test_scores) / len(test_scores)

# print the average

print(f"Average: {average:.2f}")


# print the second largest score

print(f"Second largest score: {test_scores[-2]}")


# check if any of the scores is over 100

if max(test_scores) > 100:

  print("Warning: a value over 100 has been entered")


# drop the two lowest scores

filtered_scores = test_scores[2:]


# compute the average of the remaining scores

filtered_average = sum(filtered_scores) / len(filtered_scores)

# print the average

print(f"Average (without lowest two scores): {filtered_average:.2f}")

This program first initializes a list to store the test scores and then loops 10 times to get the test scores from the user. It adds each test score to the list and then sorts the list. It then prints the highest and lowest scores, computes and prints.

Expected output:

Enter a test score: 90
Enter a test score: 80
Enter a test score: 70
Enter a test score: 60
Enter a test score: 50
Enter a test score: 40
Enter a test score: 30
Enter a test score: 20
Enter a test score: 10
Enter a test score: 0
Highest score: 90
Lowest score: 0
Average: 50.00
Second largest score: 80
Average (without lowest two scores): 66.67


This program first initializes a list to store the test scores and then loops 10 times to get the test scores from the user. It adds each test score to the list and then sorts the list. It then prints the highest and lowest scores, computes and prints the average of the test scores, prints the second largest score, checks if any of the scores is over 100 and prints a warning message if necessary, drops the two lowest scores, computes and prints the average of the remaining scores.