Pass or fail

EasyIf-Else Programs · 18 of 64

Write a Python program that reads marks and prints Pass if they are greater than 35, otherwise Fail.

Advertisement
Input
45
Output
Enter marks: 45
Pass

Approach

  1. Read the marks with input() and convert to int.
  2. Compare with 35.

Solution

Python
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.

More if-else programs

← All 64 If-Else Programs

Leave a Comment