Python Find Grade Using Nested If Else Program

By | March 19, 2020

Python Find Grade Using Nested If Else Program

Python Find Grade Using Nested If Else Program

Python Find Grade Using Nested If Else Program

 

# Write a Python program
# using nested if else statement
# to print the grade based on marks
# input by the user

# Perfect Python Programming Tutorials
# Author : www.EasyCodebook.com (c)

# Actual Program starts here 
# Python Program - Print Your Grade using nested if

marks = input("Enter Marks Obtained: ")
marks = int(marks)
if marks >= 80:
    grade = 'A'
else:
    if marks >= 70:
        grade = 'B'
    else:
        if marks >= 55:
            grade = 'C'
        else:
            if marks >= 50:
                grade = 'Pass'
            else:
                 grade = 'Fail'
print ("\nYour Grade is: " + grade)

Output 1

 
Enter Marks Obtained: 70

Your Grade is: B

Output 2

 
Enter Marks Obtained: 40

Your Grade is: Fail

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *