forked from LokeshMaradi/Types-of-Inheritance-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhierarchialinheritance.py
More file actions
31 lines (31 loc) · 934 Bytes
/
hierarchialinheritance.py
File metadata and controls
31 lines (31 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class person:
def __init__ (self,name,age):
self.name=name
self.age=age
def display(self):
print("NAME:",self.name)
print("AGE:",self.age)
class teacher(person):
def __init__(self,name,age,exp,r_area):
person.__init__(self,name,age)
self.exp=exp
self.r_area=r_area
def displaydata(self):
person.display(self)
print("EXPERIENCE:",self.exp)
print("RESEARCH AREA:",self.r_area)
class student(person):
def __init__(self,name,age,course,marks):
person.__init__(self,name,age)
self.course=course
self.marks=marks
def displaydata(self):
person.display(self)
print("COURSE:",self.course)
print("MARKS:",self.marks)
print("TEACHER")
T=teacher("jaya",43,20,"recommender systems")
T.displaydata()
print("STUDENT")
S=student("mani",20,"btech",78)
S.displaydata()