-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinherit.py
67 lines (34 loc) · 1.14 KB
/
inherit.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
print('\033c')
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):#constructor for Teacher class
Person.__init__(self,name,age) #calling constructor of parent class
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):#constructor for Student class
Person.__init__(self,name,age) #calling constructor of parent class
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", 20,"BE COMP", 79)
S.displaydata()"""""