We will see a program to illustrate the working of multiple inheritance in Python using profit/ loss example.
Problem Description: The program will calculate the net income based on the profits and losses to the person using multiple inheritance.
Multiple Inheritance in Python:
When a single class inherits properties from two different base classes, it is known as multiple inheritance.
The below diagram will make things clearer,

All Class and Methods used in the program:
- Class : Profit
- Method : getProfit() -> get input of profit from user.
- Method : printProfit() -> prints profit on screen
- Class : Loss
- Method : getLoss() -> get input of loss from user.
- Method : printLoss() -> prints loss on screen.
- Class : Balance
- Method : getBalance() -> call the getProfit() and getLoss() methods.
- Method : printBalance() -> calls printProfit() and printLoss() methods and calculates balance from profit and loss.
Program to illustrate the Multiple Inheritance in Python
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer