Write A Python Program To Find The Best Of Two Test Average Marks Out Of Three Test Marks Accepted From The User

Hi Guys, welcome to my blog in this article you will learn about how to Write A Python Program To Find The Best Of Two Test Average Marks Out Of Three Test's Marks Accepted From The User

 

Title : 

Write A Python Program To Find The Best Of Two Test Average Marks Out Of Three Test Marks Accepted From The User



Write A Python Program To Find The Best Of Two Test Average Marks Out Of Three Test Marks Accepted From The User


 

Description : 

Hi guys, in this article you will learn a python program that Takes input as test marks from the user and calculate the average of best to test marks Take three variables test1, test2 and test3, using the input function call as the user to enter the score for this test and then using the type conversion convert the text into floating point value.


    
test1 = float(input("Enter the score for Test 1: "))
test2 = float(input("Enter the score for Test 2: "))
test3 = float(input("Enter the score for Test 3: "))


    


Now using the if statement try to get the minimum of three given test, Compare test1 with test2 and test3 to get the minimum of these. Now using the else if statement, compare the test2 with test1 and test3. Finally use the else block to declare minimum score as test3


    
if test1 <= test2 and test1 <= test3:
   min_score = test1
elif test2 <= test1 and test2 <= test3:
   min_score = test2
else:
   min_score = test3


    


Once we find the minimum scores from the top 3 scores. In order to get the average of best to marks add all the three test and subtract the minimum and divided by 2


    
average = (test1 + test2 + test3 - min_score) / 2
print("The Average of Your Test is : ", average)


    




Complete Python Code : 


    
test1 = float(input("Enter the score for Test 1: "))
test2 = float(input("Enter the score for Test 2: "))
test3 = float(input("Enter the score for Test 3: "))

if test1 <= test2 and test1 <= test3:
   min_score = test1
elif test2 <= test1 and test2 <= test3:
   min_score = test2
else:
   min_score = test3

average = (test1 + test2 + test3 - min_score) / 2
print("The Average of Your Test is : ", average)


    

 

 

Output : 


    
Enter the score for Test 1: 24
Enter the score for Test 2: 25
Enter the score for Test 3: 13
The Average of Your Test is :  24.5


    

 

Output : 


    
Enter the score for Test 1: 12
Enter the score for Test 2: 24
Enter the score for Test 3: 25
The Average of Your Test is :  24.5


    



Conclusion :

The above Python program asks the user to enter the 3 marks that the student has scored in each of the three tests. The program then finds the minimum of these three tests and then subtracts it from the total of 3 then divides seats by 2 to get the average of the best two Marks. Comment it down below if you have any suggestions to improve the above Python program

 

Post a Comment

0 Comments