Multilevel inheritance in Python

Multilevel inheritance in Python

In the case of multilevel inheritance, a child class inherits from the parent class, and then there is another class, which inherits from the child class. Simply speaking, there are levels of inheritance. This is like there is some grandfather, and the father inherits some features from the grandfather, and then there is a child, which inherits some features from the father. Let’s have a look at some examples so that we can understand better about multilevel inheritance.

Multilevel Inheritance in python

As you can see, in the above program, we have created a class named GrandParent, and there is the class Father, which inherits from the GrandParent class. Again, there is the class Child, which inherits from the Father class. So here, there are some multiple levels of inheritance, and you can see that the Father class object can access the method from the GrandParent class, and also the Child class object can also access the method from the GrandParent class, and this is due to the inheritance.

Now, that we have an idea of what is multilevel inheritance, Let’s now move ahead, to see multiple inheritances. You can also refer to the diagram, which gives a clearer idea about the multilevel inheritance.