Python Inheritance

Python Inheritance:

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.

(1) Inheritance is a mechanism for creating a new class that specializes or modifies the behavior of an existing class. The original class is called a base class, superclass, or parent class. The new class is called a derived class or subclass or child class. When a class is created via inheritance, it “inherits” the attributes defined by its base classes. However, a derived class may redefine any of these attributes and add new attributes of its own.

(2) When there’s only one child class that inherits the features of its parent class, it is referred to as single inheritance as shown below.

single inheritance in python

(3) In multiple inheritance, a child class inherits the features of multiple parent classes as shown below.

multiple inheritance in python

(4) Multilevel inheritance is when we have a second child class that inherits the features of the first child class as shown below.

Multilevel inheritance in Python

(5) When we use one parent class to construct multiple subclasses we have the hierarchical inheritance.

(6) When we combine several types of inheritance we call it hybrid inheritance.

Object-Oriented Programming (OOP)
Computer Software and Hardware
Information and Communication Technology
C++ Data Types
Tokens in C++
Install MySQL on Windows
Inheritance (object-oriented programming)– Wikipedia

Comments (No)

Leave a Reply