-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathOOP-3.py
72 lines (54 loc) · 1.41 KB
/
OOP-3.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
68
69
70
71
72
'''
class PARENT:
def __init__(self):
self.a=10
def basefunc(self):
print("Base Instance Function a =",self.a)
class CHILD(PARENT):
def __init__(self):
super().__init__()
def f1(self):
super().basefunc()
self.basefunc()
obj=CHILD()
obj.f1()
'''
'''
class PARENT:
x=11
x=12#static var; returns latest value
def __init__(self):
self.a=10
@staticmethod
def basefunc():
print("Base Static Function x =",CHILD.x)
class CHILD(PARENT):
def __init__(self):
super().__init__()
@staticmethod
def f1():
CHILD.basefunc()
#self.basefunc()
obj=CHILD()
obj.f1()
'''
class PERSON:
def __init__(self,n,a):
self.name = n
self.age = a
class STUDENT(PERSON): #HI
def __init__(self,n,a,r,d):
self.rollno = r
self.defaulter = d
PERSON.__init__(self,n,a)
class TEACHER(PERSON): #HI
def __init__(self,n,a,c):
self.course = c
PERSON.__init__(self,n,a)
class BRIGHTSTUDENT(STUDENT,TEACHER): #MI
def __init__(self,n,a,r,d,c,p):
self.points = p
STUDENT.__init__(self,n,a,r,d)
TEACHER.__init__(self,n,a,c)
obj=BRIGHTSTUDENT("Rajeev",19,100,"No","Chemistry",7)
print(obj.__dict__)