Wednesday, December 8, 2021

Polymorphism in python

 polymorphism means one function with multiple forms. one function can act like multiple functions.

Example:

#polymorphism


print(len("hello"))


print(len([10,20,30]))



output:

5

3



#your defined  polymorphism


def poly_test(a,b,c=0):

    print(a+b+c)

    

poly_test(10,20)

poly_test(10,20, c=30)


output :

30

60

No comments:

Post a Comment

python class topic video