Python OOPs Concepts 10

Python Multilevel Inheritance

In Multilevel Inheritance we have a class which is base class of another class and at the same time is the derived class of another class.

class student:   
    def abc(self):  
      print('In student class...'  );
class physical(student):  
   def xyz(self):  
      print('In Physical class...'  );
class marks(physical):  
    def pqr(self):  
        print('In marks class...'  );
d=marks()  
d.abc()  
d.xyz()  
d.pqr()  

Output:

In student class...
In Physical class...
In marks class...
>>> 

Example:

class A:
    def m(self):
        print("m of A called")

class B(A):
    def m(self):
        A.m(self)
        print("m of B called")
        
    
class C(B):
    def m(self):
        B.m(self)
        print("m of C called")
        
x = C()
x.m()

Output:

m of A called
m of B called
m of C called
>>>