Python Practice › If-Else Programs › Program 18
Pass or fail
Write a Python program that reads marks and prints Pass if they are greater than 35, otherwise Fail.
Input
45
Output
Enter marks: 45 Pass
Approach
- Read the marks with
input()and convert to int. - Compare with 35.
Solution
marks = int(input("Enter marks: "))if marks > 35: print("Pass")else: print("Fail")Outputtyped input: 45
Enter marks: 45 Pass
Line by line
Line 1
input() returns text; int() converts it.
Line 2
The task says greater than 35, so exactly 35 fails.
Learn the concept
New to this topic? Read the lesson, then come back.