0% found this document useful (0 votes)
4 views1 page

Calculate Average of Best Test Scores

The document contains a Python script that calculates the average of the best two test scores from three input marks. It prompts the user to enter marks for three tests, sorts them, and computes the average of the two highest scores. In the provided example, the average of the best two scores (43, 38, and 47) is calculated to be 45.0.

Uploaded by

savitha.s
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Calculate Average of Best Test Scores

The document contains a Python script that calculates the average of the best two test scores from three input marks. It prompts the user to enter marks for three tests, sorts them, and computes the average of the two highest scores. In the provided example, the average of the best two scores (43, 38, and 47) is calculated to be 45.0.

Uploaded by

savitha.s
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

In [2]: ​

m1 = int(input("Enter marks for test1 : "))


m2 = int(input("Enter marks for test2 : "))
m3 = int(input("Enter marks for test3 : "))

# if m1 <= m2 and m1 <= m3:
# avgMarks = (m2+m3)/2
# elif m2 <= m1 and m2 <= m3:
# avgMarks = (m1+m3)/2
# elif m3 <= m1 and m2 <= m2:
# avgMarks = (m1+m2)/2

best_of_two = sorted([m1, m2, m3], reverse=True)[:2]
average_best_of_two = sum(best_of_two)/2

print("Average of best two test marks out of three test’s marks is", average_best_of_two);

Enter marks for test1 : 43


Enter marks for test2 : 38
Enter marks for test3 : 47

Average of best two test marks out of three test’s marks is 45.0

You might also like