Polymorphism (“many forms”) means that the same operation can work on objects of different types, each responding in its own way. It lets you write general code, such as “draw every shape” or “pay every employee”, without checking each object’s type.
The idea
In Python, polymorphism appears in three main ways:
Form
Meaning
Example
Duck typing
Any object with the required methods can be used, whatever its class
Any object with execute() can be passed to Animal.code()
Operator overloading
One operator, different behaviour per type
+ on numbers, lists, strings, Student
Method overriding
A subclass redefines a parent method
Square.area() replaces Shape.area()
Duck typing
“If it walks like a duck and quacks like a duck, it is a duck.” Python does not check an object’s class before calling a method; it simply calls the method. If the object has it, the call works.
Method overloading and overriding
Method overloading
Method overriding
Meaning
Several methods with the same name but different parameter lists in one class
A subclass redefines a method inherited from its parent, with the same name
Supported in Python?
No: a later def with the same name replaces the earlier one
Yes
Python alternative
Default arguments, *args, or checking argument types
super().method() reaches the parent’s version
Decided at
(In Java/C++: compile time)
Run time, by the object’s class
Key takeaways
Polymorphism: one interface, many behaviours.
Duck typing: objects are used by their methods, not their class.
Overriding: a subclass redefines a parent method; super() reaches the original.
Python has no method overloading; use default arguments or *args.
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Define polymorphism and explain its main benefit with an example from a payroll system.
Show worked answer
Polymorphism is the ability of one interface, such as a method name, to work with objects of different classes, each responding in its own way. In a payroll system, FullTimeEmployee, PartTimeEmployee and Contractor can each define pay() differently (monthly salary, hours × rate, invoice amount). The payroll code simply runs for e in employees: total += e.pay() without checking types. Adding a new kind of employee later only needs a new class with a pay() method; the payroll loop does not change.
MCA Online notes are made for reading on screen. Open https://mcastudy.online/mcs-201/classes-in-python/polymorphism/ to read this page.