7. Multiple Function Definitions
We can define multiple functions in the same Python file.
We can call any function whenever we need it.
Example:
def add():
print(5 + 10)
def subtract():
print(10 - 5)
def multiply():
print(10 * 2)
def divide():
print(100 / 2)
add()
subtract()
multiply()
divide()
Output:
15
5
20
50.0
8. Function Overloading
Function overloading means using the same function name with different numbers or types of arguments.
In languages like Java, function overloading is supported directly.
Python does not support traditional function overloading using multiple definitions. If we define the same function name again, the latest definition replaces the previous one.
Top comments (0)