Python Program to print employee details using multiple inheritance


In this program, you will learn how to print employee details using multiple inheritance in Python.


class Employee:

class Clerk:

class Manager(Employee, Clerk):

Example: How to print employee details using multiple inheritance in Python

class Employee:
    def input1(self):
        self.id = input("Enter your id:")


class Clerk:
    def input2(self):
        self.name = input("Enter your name:")
        self.sal = int(input("Enter your salary:"))


class Manager(Employee, Clerk):
    def view(self):
        super().input1()
        super().input2()

        print("\n\n=======Employee Details==========\n")

        print("Your id is:", self.id)
        print("Your name is:", self.name)
        print("Your salary is:", self.sal)


obj = Manager()
obj.view()

Output:

Enter your id:101
Enter your name:Xiith
Enter your salary:1000


=======Employee Details==========

Your id is: 101
Your name is: Xiith
Your salary is: 1000

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.