-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_demo.py
80 lines (61 loc) · 1.86 KB
/
class_demo.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
class Student:
def __init__(self, firstName, lastName, Rollno, marks):
self.firstName = firstName
self.lastName = lastName
self.Rollno = Rollno
self.marks = marks
self.email = firstName.lower() + '.' + lastName.lower() + '@python.com'
def fullname(self):
return '{} {}'.format(self.firstName, self.lastName)
def apply_raise(self):
perc_rise = 1.05
self.marks = float(self.marks * 1.05)
class Dump (Student):
perc_rise = 1.10
def __init__(self, firstName, lastName, Rollno, marks, prog_lang):
super().__init__(firstName, lastName, Rollno, marks)
self.prog_lang = prog_lang
#objStdFirst = Student('Rajat', 'Jog', 3154533, 84.91)
#objStdSecond = Student('Swapnil', 'Sapkal', 3154528, 93.54)
Rajat = Dump('Rajat', 'Jog', 3154533, 84.91, 'Python')
Swapnil = Dump('Swapnil', 'Sapkal', 3154528, 93.54, 'MongoDB')
#print objStdFirst.email
#print Rajat.marks
#dumbObjStdFirst.marks = dumbObjStdFirst.marks * Dump.perc_rise
#print dumbObjStdFirst.marks
print Rajat.firstName
print Swapnil.prog_lang
"""
# Get Help on Derieved Class
print(help(Dump))
objStdFirst.firstName = 'Rajat'
objStdFirst.lastName = 'Jog'
objStdFirst.Rollno = 3154533
objStdFirst.marks = 84.91
objStdSecond.firstName = 'Swapnil'
objStdSecond.lastName = 'Sapkal'
objStdSecond.Rollno = 3154528
objStdSecond.marks = 93.28
"""
"""
print(objStdFirst.email)
print(objStdSecond.email)
"""
#print('{} {}'.format(objStdFirst.firstName, objStdFirst.lastName))
"""
print(objStdFirst.fullname())
print(objStdSecond.fullname())
print(objStdFirst.marks)
objStdFirst.apply_raise()
print(objStdFirst.marks)
print(objStdSecond.marks)
objStdSecond.apply_raise()
print(objStdSecond.marks)
"""
"""
# Printing whole record
print objStdFirst.__dict__
print objStdSecond.__dict__
print Student.__dict__
"""
########## INHERITANCE ###########