Page 97 - TrackpadV5.1_class8
P. 97
elif (conditional expression):
statement(s)
else:
statement(s)
Program 3: To grade a student according to his/her marks
Program3.py
File Edit Format Run Options Window Help
#Program to grade a student according to his/her marks
marks = int(input('Enter marks: '))
if(marks >=90):
print('Grade A+')
elif(marks >=80):
print('Grade A')
elif(marks >=70):
print('Grade B+')
elif(marks >=60):
print('Grade B')
elif(marks >=50):
print('You can do better!!!')
else:
print('You need to work hard!!!')
On running the above program, we get the following output:
Output
Enter the first number: 84
Grade A
THE NESTED if STATEMENTS
Nested if statements mean if statements are placed within another if statement. Python allows
us to write an if statement within another if statement. The syntax of the nested if statement is as
follows:
Control Structures in Python 95

