Ticker

6/recent/ticker-posts

Polymorphism in Python:

 Polymorphism in Python:

The word meaning for polymorphism is many forms. In greek ‘poly’ means many and ‘morphism’ means forms. In python polymorphism means using same function name for different types.

Inbuilt Polymorphic functions:

For example len( ) can be used to find the length of string and the list

 

Inbuilt Polymorphic functions in Python

Polymorphism with class:

Here the leg( ) method is used by both cat and parrot class

 

Polymorphism with class in Python



Polymorphism with Inheritance:

Here the method AnimalInfo( ) is used by both the cat and tiger class.

 

Polymorphism with inheritance in Python






Post a Comment

0 Comments