0% found this document useful (0 votes)
17 views4 pages

Lab 2.6 Python Program Demonstrating Multilevel Inheritance

The document is a lab manual for a Python program demonstrating multilevel inheritance through three classes: Person, Employee, and Manager. It outlines the objectives, problem statement, and procedure for implementing these classes, including the attributes and methods that are inherited at each level. The program culminates in creating a Manager object that showcases inherited details from both the Person and Employee classes.

Uploaded by

Royal Piano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views4 pages

Lab 2.6 Python Program Demonstrating Multilevel Inheritance

The document is a lab manual for a Python program demonstrating multilevel inheritance through three classes: Person, Employee, and Manager. It outlines the objectives, problem statement, and procedure for implementing these classes, including the attributes and methods that are inherited at each level. The program culminates in creating a Manager object that showcases inherited details from both the Person and Employee classes.

Uploaded by

Royal Piano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

LAB MANUAL

Python Program
Demonstrating
Multilevel
Inheritance

Disclaimer: The content is curated from online/offline resources and used for educational purpose only

Disclaimer: The content is curated from online/offline resources and used for educational purpose only
Python Program Demonstrating Multilevel Inheritance

Objectives:
 To understand and implement multilevel inheritance in Python using classes.
 To create a base class Person to store common personal details, a derived class
Employee to store employee-related details, and a further derived class Manager that
extends Employee to store manager-specific details.
 To demonstrate how attributes and methods are passed through multiple levels of
inheritance.
Problem Statement:
Create a base class Person to store common personal details such as name and age. Then, an
employee class will be derived from Person to include employee-related details such as
employee ID and salary. Finally, the Manager class will inherit from Employee and add specific
details like department and team size. The program will demonstrate how attributes and
methods are passed down through multiple levels of inheritance.

Procedure:
Task 1: Define the Base Class Person
Task 2: Define the Derived Class Employee
Task 3: Define the Further Derived Class Manager
Task 4: Instantiate Objects from the Manager Class

Code:
Task 1: Define the Base Class Person
The Person class is the base class, which contains common personal details like name and
age. The display_personal_details() method returns a string containing the person's name and
age.

Disclaimer: The content is curated from online/offline resources and used for educational purpose only
Task 2: Define the Derived Class Employee
The Employee class inherits from Person and adds employee-specific attributes like
employee_id and salary.
The __init__ method uses super() to call the constructor of the Person class to initialize the
inherited attributes (name and age).

Task 3: Define the Further Derived Class Manager


The Manager class inherits from Employee, adding specific attributes for managers like
department and team_size. The __init__ method calls the constructor of the Employee class to
initialize inherited attributes (name, age, employee_id, salary). The display_manager_details()
method displays the manager's details along with personal and employee information by calling
display_employee_details() from the Employee class.

Disclaimer: The content is curated from online/offline resources and used for educational purpose only
Task 4: Instantiate Objects from the Manager Class
An object manager is created from the Manager class with the name "Ramar Bose", age 45,
employee ID "M12345", salary of ₹95,000, department "Sales", and a team size of 10.
The display_manager_details() method is called to print all the details inherited from both
Person and Employee, as well as manager-specific details.

Output:

This program demonstrates multilevel inheritance in Python by extending functionality across


multiple levels of classes: Person, Employee, and Manager. The Manager class inherits
attributes and methods from both its parent class (Employee) and grandparent class (Person).

Disclaimer: The content is curated from online/offline resources and used for educational purpose only

You might also like