In the multiple inheritance scenario, any specified attribute or method is searched first in the current class. If not found, the search continues into parent classes in depth-first, left to right fashion without searching the same class twice. Searching in this way is called Method Resolution Order (MRO).There are three principles followed by MRO.
Understanding MRO gives us clear idea regarding which classes are executed and in which sequence. We can easily estimate the output when several base classes are involved.
A Python program to understand the order of execution of methods in several base classes according to MRO.s
When a child class inherits from only one parent class then it is called single inheritance.
When a child class inherits from multiple parent classes then it is called multiple inheritance
In multilevel inheritance, features of the base class and the derived class are further inherited into the new derived class. This is similar to a relationship representing a child and grandfather.
When more than one derived classes are created from a single base this type of inheritance is called hierarchical inheritance. In this, there will be a parent (base) class and two child (derived) classes.
Hybrid inheritance is a combination of multiple inheritance and multilevel inheritance. The class is derived from the two classes as in the multiple inheritance. However, one of the parent classes is not the base class. It is a derived class.
Hybrid Inheritance combines more than one form of inheritance. It is a blend of more than one type of inheritance.