Python Program to print student details using multilevel inheritance


In this program, you will learn how to print student details using multilevel inheritance in Python.


class Student:
     //statement

class Test(Student):
    //statement

class Admin(Test):
   //statement

Example: How to print student details using multilevel inheritance in Python

class Student:
    def __init__(self):
        self.name = input("Enter your name:")
        self.cname = input("Enter your college name:")
        self.roll = int(input("Enter your roll number:"))
        self.marks = int(input("Enter your marks:"))

class Test(Student):
    def check(self):
        if self.marks > 60:
            print("Your are valid for next level:", self.marks)
        else:
            print("Your are not valid for next level:", self.marks)

class Admin(Test):
    def display(self):
        print("============ Student info is ==========")
        print("Name is : ", self.name)
        print("College Name is : ", self.cname)
        print("Roll number is : ", self.roll)

obj = Admin()
obj.display()
obj.check()

Output:

Enter your name:Xiith
Enter your college name:Xiith34
Enter your roll number:101
Enter your marks:90
============ Student info is ==========
Name is :  Xiith
College Name is :  Xiith34
Roll number is :  101
Your are valid for next level: 90