-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathassignment10_inheritance.py
More file actions
93 lines (75 loc) · 1.75 KB
/
assignment10_inheritance.py
File metadata and controls
93 lines (75 loc) · 1.75 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
print("question 1")
class animal:
def show(self):
print("this is the animal class")
class tiger(animal):
def display(self):
print("this is the tiger class")
t1=tiger()
t1.display()
t1.show()
print("question 2")
#Q.2- What will be the output of following code.
class A:
def f(self):
return self.g()
def g(self):
return ('A')
class B(A):
def g(self):
return ('B')
a = A()
b = B()
print(a.f(), b.f())
print(a.g(), b.g())
#output
#A B
#A B
print("question 3")
class cop:
def add(self,name,age,work,experience,designation):
self.name=name
self.age=age
self.work=work
self.experience=experience
self.designation=designation
def display(self):
print(self.name)
print(self.age)
print(self.work)
print(self.experience)
print(self.designation)
def update(self,name,age,work,experience,designation):
self.name=name
self.age=age
self.work=work
self.age=age
self.experience=experience
self.designation=designation
class mission(cop):
def add_mission_details(self,mission):
self.mission=mission
print(self.mission)
m1=mission()
m1.add_mission_details("filled work")
m1.add('rahul',19,"DS","5years","DM")
m1.display()
m1.update('tiwari',19,"DA","8years","DM")
m1.display()
print("question 4")
class shape:
def __init__(self,length,breadth):
self.length=length
self.breadth=breadth
class rectangle(shape):
def area(self):
area=self.length*self.breadth
print(area)
class square(shape):
def area(self):
area=self.length*self.breadth
print(area)
m1=rectangle(3,9)
m1.area()
m2=square(5,5)
m2.area()