Tutorial 4: OOPs in Python — Polymorphism

Photo by Hitesh Choudhary on Unsplash

Missed previous lecture ?? — Click here

In this tutorial we will cover following topics :

Polymorphism

Polymorphism in Python’s built-in functions

Polymorphism in Python’s user-defined class functions

help() function for built-in class and user-defined class

Polymorphism

Polymorphism = Poly + morphs

Poly means many and morph means form.

Here ‘Polymorphism’ = same function(method) name with different functionalities for different classes

Polymorphism in Python’s built-in functions

Polymorphism in Python’s user-defined class functions :

Let’s understand polymorphism using examples :

Example 1

Example 2

help() function for built-in class and user-defined class :

Let’s appreciate the beauty of Python language .

help() function in python gives general information about any python object if passed inside parentheses. As you can see below it works for built-in class ‘list’.

Let’s see if help() function works for user-defined class object.

Yes it works !!!.

You can see above when help() function is called for ‘num_square’ object , __init__ and area() methods are also mentioned including the number of attributes every method takes.

Congratulations !!

You have completed fourth tutorial. Take a deep breathe and move to the next tutorial.

--

--

--

I am a keen learner and diligent teacher with special interest in mathematics and machine learning.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

In a Hadoop cluster, how to contribute limited/specific amount of storage as slave to the cluster?

(GCP vs AWS vs Azure )War of the Giants.

bitBybit: A brand new way to pay!

Spring Boot — A Quick Start

Python VS Java as your Starting Programming Language

Why you shouldn’t take Flutter as just another cross platform for mobile apps

How is it better for 2 persons to manage data together using Podio?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gaurav Patil

Gaurav Patil

I am a keen learner and diligent teacher with special interest in mathematics and machine learning.

More from Medium

Tutorial 3 : OOPs in Python — Inheritance

10 useful String Operations in Python

Python Unknown (Tips and Tricks) — Part 1

Can You Solve This in Python?