-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle.py
More file actions
75 lines (64 loc) · 1.15 KB
/
single.py
File metadata and controls
75 lines (64 loc) · 1.15 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
'''single inheritance
class a:
def fun1(self):
print("fun1")
def fun2(self):
print("fun2")
class b(a):
def fun3(self):
print("fun3")
def fun4(self):
print("fun4")
o=a()
p=b()
p.fun1()'''
'''multiple inheritance
class a:
branch="cse"
def __init__(self,x):
self.x=x
def fun1(self):
print("fun1")
print(self.x)
print(a.branch,o.x)
def fun2(self):
print("fun2")
class b:
def __init__(self):
print("1")
def fun(self):
print("fun3")
def fun(self):
print("fun4")
class c(a,b):
def fun(self):
print("fun")
o=a(5)
p=b()
q=c()
#q.fun2()
q.fun(10)
#p.fun()
o.fun1()'''
'''variables in inheritance
class a:
branch='cse'
def __init__(self,x):
self.x=x
def fun(self):
print(o.x,a.branch)
o=a(5)
o.fun()'''
class a:
def __init__(self,a,b):
self.a=a
self.b=b
def add(self):
print(self.a+self.b)
class b(a):
def fun(self):
pass
p=a(5,4)
p.add()
q=b(4,4)
q.add()