Python Tutorial
About Lesson

In this Python lesson we want to learn about Python Multi Level Inheritance, in object oriented programming when you inherits a derived class from another derived class this is called multi level inheritance and it can be done at any depth.

 

 

Now let’s take a look at this image.

Python Multi Level Inheritance
Python Multi Level Inheritance

 

 

If you see in the above image we have three classes, we have a Class A, this class is our base class. we have another Class B, this class extends from the base Class A. we have another Class C, now this class extends from Class B. as we have already said when you extends a derived class from another derived class this is called multi level inheritance and it can be done at any depth. now our Class B can access to all attributes and method of the Class A, and our Class C can access to all attributes and methods of the Class A and Class B.

 

 

Now let’s create a practical example, in this example we have our base class that is class Person, in this class we have created a method. we have two more classes, one is class Student and it is extending from class Person, there is a method in this class. also we have another class that is class Programmer, this class extends from the Student class. now if you create the instance of the Programmer class, this class can access to the method of the Person and Student classes.

 

 

 

Run the code and this is the result.

Python Multi Level Inheritance
Python Inheritance Type Example

 

 

 

As i have already said you can create Python Multi Level Inheritance at any depth.

 

Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.
Exercise Files
No Attachment Found
No Attachment Found