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

Extra

The document defines three Python classes - person, employee, and Teacher - where Teacher inherits from both person and employee and adds an additional load attribute. Main code creates instances of each class and prints them to demonstrate their functionality.

Uploaded by

mr. crazy
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 views2 pages

Extra

The document defines three Python classes - person, employee, and Teacher - where Teacher inherits from both person and employee and adds an additional load attribute. Main code creates instances of each class and prints them to demonstrate their functionality.

Uploaded by

mr. crazy
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
You are on page 1/ 2

class person (object):

def __init__(self,name,gender) :

self.name = name

self.gender = gender

def __str__ (self) :

return "name : " + str(self.name) + "\ngender : "+str(self.gender)

def display (self) :

print(self)

class employee (object) :

def __init__ (self,id,salary) :

self.id = id

self.salary = salary

def __str__ (self) :

return "id : " + str(self.id) + "\nsalary : "+str(self.salary)

def display (self) :

print(self)

class Teacher (person,employee) :

def __init__(self,name,gender,id,salary,load) :

person.__init__(self,name,gender)

employee.__init__(self,id,salary)

self.load = load

def __str__(self) :

st = ""

st +=person.__str__(self) + "\n"

st +=employee.__str__(self) + "\n"

st +="Load : " + str(self.load)

return st

def display (self) :


print(self)

# main code

person1 = person("yaser" , "male")

print(person1)

employee1 = employee(21234567891,100)

print(employee1)

print()

teacher1 = Teacher("ahmmad","male",123456789,200,15)

print(teacher1)

You might also like