Hierarchical Inheritance in Python || Employee Class || Hierarchical Inheritance || Python
In this we are going to see a program of employee class using hierarchical inheritance in Python Programming Language.



class GParent:
    def __init__(self, name, id, salary):
        self.name = name
        self.id = id
        self.salary = salary

    def Employee_Details(self):
        return self.id, self.name, self.salary

    def Employee_check(self):
        if self.id > 500000:
            return " Valid Employee "
        else:
            return " Invalid Employee "

class Parent_class1(GParent):
    pass


class Parent_class2(GParent):
    def msg(self):
        print("Employee check!!!")


class last_class:
    def end(self):
        print(" END OF PROGRAM ")


Employee1 = Parent_class1("Employee1", 198754, 150000)
Employee2 = Parent_class2("Employee2", 600445, 240000)
Employee2.msg()
print(Employee1.Employee_Details(), Employee1.Employee_check())
print(Employee2.Employee_Details(), Employee2.Employee_check())

e = last_class()
e.end()

# Coded by Saahil


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post