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

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.