-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInheritance.py
More file actions
41 lines (29 loc) · 805 Bytes
/
Inheritance.py
File metadata and controls
41 lines (29 loc) · 805 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
35
36
37
38
39
40
41
# Inheritance
class grandparent () :
def feature1 () :
print("feature1 included")
# inheriting grandparent
# single level inheritance
class parent (grandparent) :
def feature2 () :
print("feature2 included")
# inheriting parent
# multi level inheritance
class child (parent) :
def feature3 () :
print("feature3 included")
class relative () :
def feature4 () :
print("feature4 included")
## inheriting relative, grandparent
# multiple inheritance
class relativeschild (relative, grandparent) :
def feature5 () :
print("feature5 included")
child1 = child ()
child.feature1()
child.feature2()
child.feature3()
relativeschild.feature1()
relativeschild.feature4()
relativeschild.feature5()