Dremendo Tag Line

Input subject marks and check pass or fail in Python

if elif - Question 9

In this question, we will see how to input marks of English, Math and Computer of a student and check whether he is pass in the examination or not in Python programming using the if elif statement. To know more about if elif statement click on the if elif statement lesson.

Q9) Write a program in Python to input marks of English, Math and Computer of a student and check whether he is pass in the examination or not. For passing in an examination one must get above 40 in at least two subjects or the average of the three subjects must be greater than 40.

Program

print('Enter marks obtained in 3 subjects')
s1=int(input())
s2=int(input())
s3=int(input())
avg=(s1+s2+s3)/3

if s1>40 and s2>40:
    print('Pass')
elif s2>40 and s3>40:
    print('Pass')
elif s3>40 and s1>40:
    print('Pass')
elif avg>40:
    print('Pass')
else:
    print('Fail')

Output

Enter marks obtained in 3 subjects
56
34
45
Pass
video-poster