Python Method Overloading

If a method is written such that it can perform more than one task, it is called method overloading.We see method overloading in the languages like Java. For example, we call a method as:

sum(10, 15)

sum(10, 15, 20)

In the first call, we are passing two arguments and in the second call, we are passing three arguments. It means, the sum() method is performing two distinct operations: finding sum of two numbers or sum of three numbers.This is called method overloading.


A Python program to show method overloading to find sum of two or three numbers.


Here the sum() method is calculating sum of two or three numbers and hence it is performing more than one task. Hence it is an overloaded method. In this way, overloaded methods achieve polymorphism.