-
Notifications
You must be signed in to change notification settings - Fork 0
/
method overriding.py
393 lines (313 loc) · 11.9 KB
/
method overriding.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
import logging
logging.basicConfig(filename="method overriding.log", level=logging.INFO, format= '%(levelname)s %(asctime)s %(name)s %(message)s')
# Example 1
class ineuron3:
logging.info("This is a class called ineuron3")
try:
logging.info("Creating different methods")
def student_name3(self):
print("List the names of all the student enrolled in ineuron3")
logging.info("List the names of all the student enrolled in ineuron3")
def no_of_courses3(self):
print("List the number of courses each student is enrolled in")
logging.info("List the number of courses each student is enrolled in")
except Exception as e:
logging.exception(e)
print(e)
class ineuron_3:
logging.info("This is another class called ineuron_3")
try:
logging.info("Creating an ovveriding method")
def student_name3(self):
print("List the names of only those students that are enrolled in the FSDS course")
logging.info("List the names of only those students that are enrolled in the FSDS course")
except Exception as e:
logging.exception(e)
print(e)
iv3 = ineuron3()
iv3.student_name3()
logging.info(iv3.student_name3())
iv_3 = ineuron_3()
iv_3.student_name3()
logging.info(iv_3.student_name3())
# Example 2
class student3:
logging.info("This is a class called student3")
try:
logging.info("Creating different methods")
def student_name3(self):
print("List out all the names of the students")
logging.info("List out all the names of the students")
def enrollment_no3(self):
print("List out the enrollment numbers of all the students")
logging.info("List out the enrollment numbers of all the students")
def id_no3(self):
print("List out the id number of all the students")
logging.info("List out the id number of all the students")
except Exception as e:
logging.exception(e)
print(e)
class student_3:
logging.info("This is another class called student_3")
try:
logging.info("Creating an overriding method")
def id_no3(self):
print("List out the id number of only those students whose id number ends with 3")
logging.info("List out the id number of only those students whose id number ends with 3")
except Exception as e:
logging.exception(e)
print(e)
s3 = student3()
s3.id_no3()
logging.info(s3.id_no3())
s_3 = student_3()
s_3.id_no3()
logging.info(s_3.id_no3())
# Example 3
class courses3:
logging.info("This is a class called course3")
try:
logging.info("Creating different methods")
def course_name3(self):
print("List out all the names of the courses offered")
logging.info("List out all the names of the courses offered")
def no_of_courses3(self):
print("List the total number of courses offered")
logging.info("List the total number of courses offered")
except Exception as e:
loggin.exception(e)
print(e)
class courses_3:
logging.info("This is another class called courses_3")
try:
logging.info("Creating an overriding method")
def course_name3(self):
print("List the names that are being offered in this semester only")
logging.info("List the names that are being offered in this semester only")
except Exception as e:
loggin.exception(e)
print(e)
c3 = courses3()
c3.course_name3()
logging.info(c3.course_name3())
c_3 = courses_3()
c_3.course_name3()
logging.info(c3.course_name3())
# Example 4
class blogs3:
logging.info("This is a class called blogs3")
try:
logging.info("Creating different methods")
def blog_title3(self):
print("List out all the blogs available on the website")
logging.info("List out all the blogs available on the website")
def no_of_blogs3(self):
print("List out the total number of blogs on the website")
logging.info("List out the total number of blogs on the website")
except Exception as e:
logging.exception(e)
print(e)
class blogs_3:
logging.info("This is another class called blog_3")
try:
logging.info("Creating an overriding method")
def blog_title3(self):
print("List out only the blogs related to Data Science")
logging.info("List out only the blogs related to Data Science")
except Exception as e:
logging.exception(e)
print(e)
b3 = blogs3()
b3.blog_title3()
logging.info(b3.blog_title3())
b_3 = blogs_3()
b_3.blog_title3()
logging.info(b_3.blog_title3())
# Example 5
class internship3:
logging.info("This is a class called internship3")
try:
logging.info("Creating different methods")
def student_name3(self):
print("List out the names of all the students")
logging.info("List out the names of all the students")
def student_id_no3(self):
print("List out the id number of all the students")
logging.info("List out the id number of all the students")
def internship_duration3(self):
print("List out the internship duration of all the domains")
logging.info("List out the internship duration of all the domains")
except Exception as e:
logging.exception(e)
print(e)
class internship_3:
logging.info("This is another class called internship_3")
try:
logging.info("Creating an overriding method")
def students_name3(self):
print("List out only the name of students that are eligible for internship")
logging.info("List out only the name of students that are eligible for internship")
except Exception as e:
logging.exception(e)
print(e)
intern3 = internship3()
intern3.student_name3()
logging.info(intern3.student_name3())
intern_3 = internship_3()
intern_3.students_name3()
logging.info(intern_3.students_name3())
# Example 6
class jobs3:
logging.info("This is a class called jobs3")
try:
logging.info("Creating different methods")
def emp_name3(self):
print("List out the names of all the employees")
logging.info("List out the names of all the employees")
def emp_id3(self):
print("List out the id numbers of all the employees")
logging.info("List out the names of all the employees")
def emp_salary3(self):
print("List out the salary of all the employees")
logging.info("List out the salary of all the employees")
except Exception as e:
logging.exception(e)
print(e)
class jobs_3:
logging.info("This is another class called jobs_3")
try:
logging.info("Creating an overriding method")
def emp_salary3(self):
print("List out the salaries of only the employees working in the data department")
logging.info("List out the salaries of only the employees working in the data department")
except Exception as e:
logging.exception(e)
print(e)
j3 = jobs3()
j3.emp_salary3()
logging.info(j3.emp_salary3())
j_3 = jobs_3()
logging.info(j_3.emp_salary3())
# Example 7
class affilates3:
logging.info("This is a class called affilates3")
try:
logging.info("Creating different methods")
def affilates_name3(self):
print("List out the name of all the affilates")
logging.info("List out the name of all the affilates")
def no_of_affilates3(self):
print("List the number of affilates")
logging.info("List the number of affilates")
except Exception as e:
logging.exception(e)
print(e)
class affilates_3:
logging.info("This is another class called affilates_3")
try:
logging.info("Creating an overriding method")
def affilates_name3(self):
print("List out the name of affilates that are related to finance sector")
logging.info("List out the name of affilates that are related to finance sector")
except Exception as e:
logging.exception(e)
print(e)
a3 = affilates3()
a3.affilates_name3()
logging.info(a3.affilates_name3())
a_3 = affilates_3()
a_3.affilates_name3()
logging.info(a_3.affilates_name3())
# Example 8
class class_type3:
logging.info("This is a class called class_type3")
try:
logging.info("Creating different methods")
def student_name3(self):
print("List out the names of all the students")
logging.info("List out the names of all the students")
def course_name3(self):
print("List out the names of all the courses offered")
logging.info("List out the names of all the courses offered")
except Exception as e:
logging.exception(e)
print(e)
class class_type_3:
logging.info("This is another class called class_type_3")
try:
logging.info("Creating an overriding method")
def course_name3(self):
print("List out only the name of courses that are being offered this semester")
logging.info("List out only the name of courses that are being offered this semester")
except Exception as e:
logging.exception(e)
print(e)
ct3 = class_type3()
ct3.course_name3()
logging.info(ct3.course_name3())
ct_3 = class_type_3()
ct_3.course_name3()
logging.info(ct_3.course_name3())
# Example 9
class student_portal3:
logging.info("This is a class called student_portal3")
try:
logging.info("Creating different methods")
def student_id3(self):
print("List out the id number of all the students")
logging.info("List out the id number of all the students")
def student_password3(self):
print("List out the passowards of all the students")
logging.info("List out the passowards of all the students")
except Exception as e:
logging.exception(e)
print(e)
class student_portal_3:
logging.info("This is another class called student_portal_3")
try:
logging.info("Creating an overriding function")
def student_id3(self):
print("List out the id number of only those students that have registered for this session")
logging.info("List out the id number of only those students that have registered for this session")
except Exception as e:
logging.exception(e)
print(e)
st3 = student_portal3()
st3.student_id3()
logging.info(st3.student_id3())
st_3 = student_portal_3()
st_3.student_id3()
logging.info(st_3.student_id3())
# Example 10
class hackathon3:
logging.info("This is a class called hackathon3")
try:
logging.info("Creating different methods")
def team_name3(self):
print("List out the names of all the teams")
logging.info("List out the names of all the teams")
def no_of_team_members3(self):
print("List out the total number of team members")
logging.info("List out the total number of team members")
def project_title3(self):
print("List out the all project titles")
logging.info("List out the all project titles")
except Exception as e:
logging.exception(e)
print(e)
class hackathon_3:
logging.info("This is another class called hackathon_3")
try:
logging.info("Creating an overriding method")
def no_of_team_members3(self):
print("List out the number of team memebers in each team")
logging.info("List out the number of team memebers in each team")
except Exception as e:
logging.exception(e)
print(e)
hat3 = hackathon3()
hat3.no_of_team_members3()
logging.info(hat3.no_of_team_members3())
hat_3 = hackathon_3()
hat_3.no_of_team_members3()
logging.info(hat_3.no_of_team_members3())