Skip to content
Home » Python Programs » Maximum of Two Numbers in Python Using Function

Maximum of Two Numbers in Python Using Function

Basic program to find maximum of two numbers in python using function. In this program, we can execute the python program to check the greatest or largest number in python using function.

Function Definition in Python

A function is a piece of code that only executes when called. If a return statement is given, Python functions return a value. After a function has been declared, it can be invoked from anywhere. The “def ” command is followed by the function name and parentheses (()) in Python to define a function.

max() Function in Python

The max() method returns the highest-valued item or the highest-valued item in an iterable. The max() method in Python returns the most significant item in an iterable or the most significant of two or more inputs.

Maximum of Two Numbers in Python Using Function

a = 2
b = 4
maximum = max(a, b)
print(maximum)

Output:

4