We will see a program to illustrate the working of multilevel inheritance in Python.
Problem Description: The program will calculate the final salary of an employee from basic salary using multilevel inheritance.
Multilevel Inheritance in Python:
Multilevel inheritance in programming (general in object-oriented program). When a base class is derived by a derived class which is derived by another class, then it is called multilevel inheritance.
The below diagram will make things clearer,

All Class used in the program and the methods:
- Class: Employee
- Method: getEmployee() -> gets user input from id, name and salary.
- Method: printEmployeeDetails() -> prints employee detail
- Method: getSalary() -> return the salary of the employee.
- Class: Perks
- Method: calcPerks() -> calculates all perks using the salaries.
- Method: putPerks() -> prints all perks.
- Method: totalPerks() -> return the sum of all perks.
- Class : NetSalary:
- Method: getTotal() -> calculates net Salary using perks and base salary.
- Method: showTotal() -> prints total salary.
Program to illustrate multilevel inheritance in Python
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer