What is polymorphism and how is it used?medium
Answer
Polymorphism allows objects of different types to be treated through a shared interface, with each type providing its own implementation of the interface methods.
Explanation
Runtime (dynamic) polymorphism uses method overriding through inheritance or interfaces - the actual method called is determined at runtime. Compile-time (static) polymorphism uses method overloading. Polymorphism enables the open-closed principle: add new types without modifying existing code that uses the interface.
Follow-upHow does duck typing in Python relate to polymorphism?