Interview Question

What is polymorphism?

Polymorphism lets one operation work with different compatible object types.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

Polymorphism means different objects can support the same operation with type-appropriate behavior. • Python commonly uses protocols and duck typing. • Special methods define behavior for operators and built-in operations. • Inheritance is not required when objects implement the expected interface.

💡 Simple Example

def show_length(value): print(len(value)) show_length('abc') show_length([1, 2])

Output

3 2

⚡ Quick Revision

Polymorphism lets one operation work with different compatible object types.