@@ -83,8 +83,34 @@ def buttons(self):
83
83
def screen (self ):
84
84
super ().screen ()# method to access parent class methods
85
85
print ('Display is colored as a whole.' )
86
+
87
+ class Rose :
88
+ def color (self ):
89
+ print ('Rose is Red.' )
90
+ def smell (self ):
91
+ print ('Rose has a sweet smell.' )
92
+ def stem (self ):
93
+ print ('Stem of rose have thorns.' )
94
+ def location (self ):
95
+ print ('Rose in the garden.' )
96
+
97
+ class Lotus :
98
+ def color (self ):
99
+ print ('Lotus is pink.' )
100
+ def smell (self ):
101
+ print ('Lotus has no smell.' )
102
+ def stem (self ):
103
+ print ('Stem of lotus has no thorns.' )
104
+ def location (self ):
105
+ print ('Lotus in the pond.' )
86
106
107
+ def what_location_n_color (lotus ):
108
+ lotus .location ()
109
+ lotus .color ()
87
110
111
+ def smell_the_flower (rose ):
112
+ rose .smell ()
113
+
88
114
def main ():
89
115
# instantiate: make object of the class
90
116
f = Fibonacci (0 ,1 )
@@ -121,5 +147,15 @@ def main():
121
147
samsung .buttons ()
122
148
samsung .screen ()
123
149
150
+ print ()
151
+ print ('Explaining POLYMORPHISM in python:' )
152
+ print ('Python being loosely typed language, polymorphism is inherent in this language.' )
153
+ redrose = Rose ()
154
+ redlotus = Lotus ()
155
+ for o in (redrose ,redlotus ):
156
+ what_location_n_color (o )
157
+ smell_the_flower (o )
158
+ o .color ()
159
+
124
160
125
- if __name__ == '__main__' :main ()
161
+ if __name__ == '__main__' :main ()