-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInhertance.py
67 lines (50 loc) · 1.01 KB
/
Inhertance.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
###Single inherientance
'''class parent:
a,b=10,20
def diplay(self):
print(self.a,self.b)
class child(parent):
c,d=30,40
def diplay1(self):
print(self.c,self.d)
c=child()
c.diplay()
c.diplay1()'''
##Single Inherence
'''
class parent:
def __init__(self,a,b):
self.a=a
self.b=b
def diplay1(self):
print(self.a,self.b)
class child(parent):
def __init__(self, c, d):
self.c = c
self.d = d
def diplay(self):
print(self.c, self.d)
c=child(30,40)
c.diplay()
c1=parent(50,60)
c1.diplay1()
'''
######## Multiple inheritence ############
class A:
def __init__(self):
self.str="lucky"
print("parent class A")
class B:
def __init__(self):
self.str1="Mohanty"
print("parent class B")
class C(A,B):
def __init__(self):
A.__init__(self)
B.__init__(self)
print("child c")
def display(self):
print(self.str)
print(self.str1)
c1=C()
c1.display()