-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.py
More file actions
83 lines (67 loc) · 1.48 KB
/
inheritance.py
File metadata and controls
83 lines (67 loc) · 1.48 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
# Inheritance is code resulabilty
# Single Level inheritance
class dad: # parent class
def house(self):
print("im from dad property")
class son(dad): # child class
def factory(self):
print("im from son property")
s1=son()
s1.house()
s1.factory()
# V1 override function
class app1:
def v1(self):
print("orders")
class app1_1(app1):
def v2(self):
print("return")
def v1(self):
print("refund")
a=app1_1()
a.v1()
a.v2()
# MultiLevel Inheritance
class ford:
def model1(self):
print("Ford first model")
class mustang(ford):
def model2(self):
print("mustang is second model of ford")
class person(mustang):
def driver(self):
print("IM the driver drive all car")
dr=person()
dr.driver()
dr.model1()
dr.model2()
# Heriarchial inhertiance ( Sub classes using parent class only )
class redmi:
def mi(self):
print("snapdragon processor")
class poco(redmi):
def x3(self):
print("gaming phone")
class xioami(redmi):
def c3(self):
print("camera quality")
phone=poco()
phone.x3()
phone.mi()
phone1=xioami()
phone1.c3()
phone1.mi()
# Multiple Inheritance
class ktm:
def duke(self):
print("i have a duke bike")
class yamaha:
def mt(self):
print("i have a mt bike")
class rider(yamaha,ktm): # sub class using two parent class
def riding(self):
print("i ride the all bike")
r1=rider()
r1.duke()
r1.mt()
r1.riding()