-
Notifications
You must be signed in to change notification settings - Fork 0
/
polymorphism.py
436 lines (342 loc) · 12.4 KB
/
polymorphism.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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
import logging
logging.basicConfig(filename="ploymorphism.log", level=logging.INFO, format= '%(levelname)s %(asctime)s %(name)s %(message)s')
# Example 1
class ineuron4:
logging.info("This is a class called ineuron4")
try:
logging.info("Creating a method inside the ineuron4 class called student_1")
def student_1(self):
print("List out the details of all the students")
logging.info("List out the details of all the students")
except Exception as e:
logging.exception(e)
print(e)
class ineuron_4:
logging.info("This is another class called ineuron_4")
try:
logging.info("Creating a method inside the ineuron_4 class called student_1")
def student_1(self):
print("List the details of only those students that are enrolled in the FSDS class")
logging.info("List the details of only those students that are enrolled in the FSDS class")
except Exception as e:
logging.exception(e)
print(e)
def ineuron_exetrnal(a):
try:
logging.info("This an external method called ineuron_external")
a.student_1()
except Exception as e:
logging.exception(e)
print(e)
iv4 = ineuron4()
iv_4 = ineuron_4()
ineuron_exetrnal(iv4)
ineuron_exetrnal(iv_4)
logging.info(ineuron_exetrnal(iv4))
logging.info(ineuron_exetrnal(iv_4))
# Example 2
class student4:
logging.info("This is a class called student4")
try:
logging.info("Creating a method inside the student4 class called idno_4")
def id_no4(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.info(e)
print(e)
class student_4:
logging.info("This is another class called student_4")
try:
logging.info("Creating a method inside the student_4 class called id_no4")
def id_no4(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)
def student_external(a):
try:
logging.info("This an external method called student_external")
a.id_no4()
except Exception as e:
logging.exception(e)
print(e)
s4 = student4()
s_4 = student_4()
student_external(s4)
student_external(s_4)
logging.info(student_external(s4))
logging.info(student_external(s_4))
# Example 3
class courses4:
logging.info("This is a class called courses4")
try:
logging.info("Creating a method inside the courses4 class called course_name4")
def course_name4(self):
print("List out all the names of the courses offered")
logging.info("List out all the names of the courses offered")
except Exception as e:
loggin.exception(e)
print(e)
class courses_4:
logging.info("This is another class called courses_4")
try:
logging.info("Creating a method inside the courses_4 class called course_name4")
def course_name4(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)
def courses_external(a):
try:
logging.info("This an external method called courses_external")
a.course_name4()
except Exception as e:
loggin.exception(e)
print(e)
c4 = courses4()
c_4 = courses_4()
courses_external(c4)
courses_external(c_4)
logging.info(courses_external(c4))
logging.info(courses_external(c_4))
# Example 4
class blogs4:
logging.info("This is a class called blogs4")
try:
logging.info("Creating a method inside the blogs4 class called blog_title4")
def blog_title4(self):
print("List out all the blogs available on the website")
logging.info("List out all the blogs available on the website")
except Exception as e:
logging.exception(e)
print(e)
class blogs_4:
logging.info("This is another class called blogs_4")
try:
logging.info("Creating a method inside the blogs_4 class called blog_title4")
def blog_title4(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)
def blogs_external(a):
try:
logging.info("This an external method called blogs_external")
a.blog_title4()
except Exception as e:
loggin.exception(e)
print(e)
b4 = blogs4()
b_4 = blogs_4()
blogs_external(b4)
blogs_external(b_4)
logging.info(blogs_external(b4))
logging.info(blogs_external(b_4))
# Example 5
class internship4:
logging.info("This is a class called internship4")
try:
logging.info("Creating a method inside the internship4 class called student_name4")
def student_name4(self):
print("List out the name of all the students")
logging.info("List out the name of all the students")
except Exception as e:
logging.exception(e)
print(e)
class internship_4:
logging.info("This is another class called internship_4")
try:
logging.info("Creating a method inside the internship_4 class called student_name4")
def student_name4(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)
def internship_external(a):
try:
logging.info("This an external method called internship_external")
a.student_name4()
except Exception as e:
logging.exception(e)
print(e)
intern4 = internship4()
intern_4 = internship_4()
internship_external(intern4)
internship_external(intern_4)
logging.info(internship_external(intern4))
logging.info(internship_external(intern_4))
# Example 6
class jobs4:
logging.info("This is class called jobs4")
try:
logging.info("Creating a method inside the jobs4 class called emp_salary4")
def emp_salary4(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_4:
logging.info("This is another class called jobs_4")
try:
logging.info("Creating a method inside the jobs_4 class called emp_salary4")
def emp_salary4(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)
def jobs_external(a):
try:
logging.info("This an external method called jobs_external")
a.emp_salary4()
except Exception as e:
logging.exception(e)
print(e)
j4 = jobs4()
j_4 = jobs_4()
jobs_external(j4)
jobs_external(j_4)
logging.info(jobs_external(j4))
logging.info(jobs_external(j_4))
# Example 7
class affilates4:
logging.info("This is a class called affilates4")
try:
logging.info("Creating a method inside the affilates4 class called affilates_name4")
def affilates_name4(self):
print("List out the name of all the affilates")
logging.info("List out the name of all the affilates")
except Exception as e:
logging.info(e)
print(e)
class affilates_4:
logging.info("This is another class called affilates_4")
try:
logging.info("Creating a method inside the affilates_4 class called affilates_name4")
def affilates_name4(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.info(e)
print(e)
def affilates_external(a):
try:
logging.info("This an external method called affilates_external")
a.affilates_name4()
except Exception as e:
logging.info(e)
print(e)
a4 = affilates4()
a_4 = affilates_4()
affilates_external(a4)
affilates_external(a_4)
logging.info(affilates_external(a4))
logging.info(affilates_external(a_4))
# Example 8
class class_type4:
logging.info("This is a class called class_type4")
try:
logging.info("Creating a method inside the class_type4 class called course_name4")
def course_name4(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_4:
logging.info("This is another class called class_type_4")
try:
logging.info("Creating a method inside the class_type_4 called course_name4")
def course_name4(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)
def class_type_external(a):
try:
logging.info("This an external method called affilates_external")
a.course_name4()
except Exception as e:
logging.exception(e)
print(e)
ct4 = class_type4()
ct_4 = class_type_4()
class_type_external(ct4)
class_type_external(ct_4)
logging.info(class_type_external(ct4))
logging.info(class_type_external(ct_4))
# Example 9
class student_portal4:
logging.info("This is a class called student_portal4")
try:
logging.info("Creating a method inside the student_portal4 class called student_id4")
def student_id4(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_portal_4:
logging.info("This is another class called student_portal_4")
try:
logging.info("Creating a method inside the student_portal_4 class called student_id4")
def student_id4(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)
def student_portal_external(a):
try:
logging.info("This an external method called affilates_external")
a.student_id4()
except Exception as e:
logging.exception(e)
print(e)
sp4 = student_portal4()
sp_4 = student_portal_4()
student_portal_external(sp4)
student_portal_external(sp_4)
logging.info(student_portal_external(sp4))
logging.info(student_portal_external(sp_4))
# Example 10
class hackathon4:
logging.info("This is a class called hackathon4")
try:
logging.info("Creating a method inside the hackathon4 class called no_of_team_members4")
def no_of_team_members4(self):
print("List out the total number of team members")
logging.info("List out the total number of team members")
except Exception as e:
logging.exception(e)
print(e)
class hackathon_4:
logging.info("This is another class called hackathon_4")
try:
logging.info("Creating a method inside the hackathon_4 class called no_of_team_members4")
def no_of_team_members4(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)
def hackathon_external(a):
try:
logging.info("This is an external method called hackathon_external")
a.no_of_team_members4()
except Exception as e:
logging.exception(e)
print(e)
hat4 = hackathon4()
hat_4 = hackathon_4()
hackathon_external(hat4)
hackathon_external(hat_4)
logging.info(hackathon_external(hat4))
logging.info(hackathon_external(hat_4))