-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.py
More file actions
34 lines (33 loc) · 950 Bytes
/
inheritance.py
File metadata and controls
34 lines (33 loc) · 950 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
32
33
34
class Person:
def __init__(self,name,age):
self.name=name
self.age=age
def display(self):
print("Name",self.name)
print("Age"=self.age)
p=Person("John",32)
p.display()
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("John",35,15,"Computer Network")
T.displaydata()
print("***********Student************")
S=Student("Raj",28,"BE COMP",79)
S.displaydata()