You are on page 1of 7

Polymorphism

Module 1 Subtopic 4

medium.com
LEARNING OBJECTIVES
At the end of this lesson, the students should
be able to:

1. Understand what is Object Oriented “Before software can


Python; be reusable it first has
2. Explain the fundamentals of Object to be usable.” – Ralph
Oriented Programming in Python; Johnson
3. Attempt to use the different
approaches in Object Oriented
Python Programming
Polymorphism in Python
 Polymorphism in OOP is the ability of an object to take many forms. In
simple words, polymorphism allows us to perform the same action in
many different ways.
 Polymorphism is taken from the Greek words Poly (many) and morphism
(forms). Polymorphism defines the ability to take different forms.
 For example, the student can act as a student in college, act as a player
on the ground, and as a daughter/brother at home. In the programming
language, the + operator, acts as a concatenation and arithmetic
addition.
Polymorphism
In this example, calculate_area()
instance method created in both
Circle and Rectangle class. Thus, we
can create a method that takes any
object and calls the object's
calculate_area() method to
implement polymorphism. Both
objects calculate the area (same
action) but in a different way
(different formulas).

Output:
Polymorphism with Inheritance

Output:
“The beautiful thing about learning is that nobody can take it away
from you.” – B.B. King
References:
https://realpython.com/python3-object-oriented-programming/
https://www.programiz.com/python-programming/object-oriented-programming
https://www.programiz.com/python-programming/class
https://www.tutorialspoint.com/python/python_classes_objects.htm
https://pynative.com/python-polymorphism/
https://pynative.com/python/object-oriented-programming/

You might also like