Skip to content

Commit 7607944

Browse files
authored
Merge pull request #1 from rohankumara/patch-1
Add files via upload
2 parents a555c11 + 8eb7e3b commit 7607944

File tree

1 file changed

+78
-5
lines changed

1 file changed

+78
-5
lines changed

oop.py

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Student1:
8080
def __init__(self,name,rollno):
8181
self.name = name
8282
self.rollno = rollno
83-
self.lap = self.laptop() # make class objector in construcor
83+
self.lap = self.Laptop() # make class objector in construcor
8484

8585

8686
def show(self):
@@ -93,12 +93,85 @@ def __init__(self):
9393
self.cpu = "i7"
9494
self.ram = 8
9595

96-
t1 = Student("Rohan",98123)
97-
t2 = Student("Ravindi",98615)
96+
t1 = Student1("Rohan",98123)
97+
t2 = Student1("Ravindi",98615)
9898

9999
lap1 = t1.lap
100100
lap2 = t2.lap
101101

102102

103-
104-
103+
#inheritance in python
104+
105+
class A: #1st class(Super class)
106+
def __init__(self):
107+
print("A init")
108+
def method1(self):
109+
print("This is method 1")
110+
def method2(self):
111+
print("This is method 2")
112+
def method3(self):
113+
print("This is method 3")
114+
def methodd(self):
115+
print("This is class D but in A")
116+
117+
#singal class inheritance
118+
#one super class & one sub class
119+
# for inharite class we use with in () we use class name tharefor we can inharite uper class from down class
120+
class B(A): # 2nd class
121+
def method4(self):
122+
print("This is method 4")
123+
def method5(self):
124+
print("This is method 5")
125+
def method6(self):
126+
print("This is method 6")
127+
128+
#now we can use uper class method form class B object
129+
130+
obj1 = B()
131+
obj1.method1()
132+
133+
#multi level inharitance
134+
#one supper class and 2 sub class
135+
class C(B): #3rd class(Super class)
136+
def __init__(self):
137+
print("class C constructr")
138+
139+
def method7(self):
140+
print("This is method 7")
141+
def method8(self):
142+
print("This is method 8")
143+
def method9(self):
144+
print("This is method 9")
145+
146+
obj2 = C()
147+
obj2.method2()
148+
149+
#multipule inheritance you can use more class in this method like this
150+
151+
class D:
152+
def __init__(self):
153+
print("This is class D constructer")
154+
155+
def methodd(self):
156+
print("This is class D")
157+
158+
159+
class F:
160+
def __init__(self):
161+
print("This is class F constructrer")
162+
163+
def methodf(self):
164+
print("this is clss F")
165+
166+
class I(C,D,F): # multiple inharitance use like this
167+
def __init__(self):
168+
super().__init__() # hear i call class supper class constructor but hear, have 3 supper class what int can be call?
169+
print("in F in init")
170+
# it's call from left to right
171+
#fristly call constructer in c then call D
172+
#it's called Method Resolution Order(MRO)
173+
174+
175+
obji = I()
176+
177+

0 commit comments

Comments
 (0)