Tutorial 4: OOPs in Python — Polymorphism
Missed previous lecture ?? — Click here
In this tutorial we will cover following topics :
Polymorphism = Poly + morphs
Poly means many and morph means form.
Here ‘Polymorphism’ = same function(method) name with different functionalities for different classes
Polymorphism in Python’s built-in functions
Polymorphism in Python’s user-defined class functions :
Let’s understand polymorphism using examples :
help() function for built-in class and user-defined class :
Let’s appreciate the beauty of Python language .
help() function in python gives general information about any python object if passed inside parentheses. As you can see below it works for built-in class ‘list’.
Let’s see if help() function works for user-defined class object.
Yes it works !!!.
You can see above when help() function is called for ‘num_square’ object , __init__ and area() methods are also mentioned including the number of attributes every method takes.
You have completed fourth tutorial. Take a deep breathe and move to the next tutorial.