
There are two types of Python inheritance:ġ. This concept of substitution is called the Liskov substitution principle. The “Apple” class inherits the interface and implementation of the base class “Fruit”, such that Apple objects can replace Fruit objects without changing any of the desired properties in an application. The simple relationship between the two classes says that “Apple” is a “Fruit”. Let’s say there exists a class “Fruit”, and you derive from it to create a new class called “Apple”. Let’s better understand the concept of Python inheritance through an example. Which inheritance is not supported in Python? Inheritance in Python


The relationship between the two classes is represented as an arrow pointing from the derived class to the base class.ģ.1.4 Q4. We show both the derived and base classes as boxes with the class name written towards the top. In the Unified Modeling Language (UML), we represent inheritance as shown: On the other hand, a derived class is also referred to as a subclass or subtype. A base class is also called a superclass. We refer to the new class as the derived (child) class, and the class from which it inherits is called the base (parent) class.

With the help of Python inheritance, we can create a new class without making any changes to an already existing class. It helps us direct the design of an application and determines how an application should grow when we add new features or when the requirements change. Did you know that Python inheritance follows the same concept as an inheritance in living beings? It is one of the most crucial concepts in object-oriented programming and helps us create a relationship between two classes.
