Page 95 - Trackpad_V2.1_class8
P. 95
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 Start
Nested if statements mean if statements are
placed within another if statement. Python False
allows us to write an if statement within if condition 1 Statement 3
another if statement. The syntax of the nested
if statement is as follows: True
if (conditional expression1): False
if condition 2 Statement 2
statement(s)
if (conditional expression2):
True
statement(s)
Statement 1
elif (conditional expression3):
statement(s)
Stop
Control Structures in Python 93

