0
334views
Write a python program to implement multiple inheritances.
1 Answer
0
3views

Solution:

Inheritance allows us to define a class that inherits all the methods and properties from another class.

The Parent class is the class being inherited from, also called the base class. The Child class is the class that inherits from another class also called the derived class.

Python Multiple Inheritance:

A class can be derived from more than one base class in Python, like C++. This is called multiple inheritances.

In multiple inheritances, the features of all the base classes are inherited into the derived class. The syntax for multiple inheritances is like a single inheritance.

enter image description here

Example of Multiple Inheritance:

Here, the father and Mother are the Base classes where we have two print statements and a child class that contains all the methods of the father and mother classes.

The child class is also known as the Derived class.

We are creating the object for the child class through which we can access the functions of the father, mother, and child.

enter image description here

Output:

enter image description here

Please log in to add an answer.