How To Find Maximum of two numbers in Python?

Python

Nicesnippets

372

07-07-2021


Hello guys,

Now let's see example of how to get maximum of two number in python. I would like to share with you find max of two number using python. We will show python get max number of two number.

In this article, I will give simple and easy way to get maximum number of two number using python.

Here i will give you two example for how to get max number of two number in python. So let's see the below example:

Example 1


#find maximum number of two number

def findMaximum(a, b):

if a >= b:

return a

else:

return b

# Driver code

a = 2

b = 4

print(findMaximum(a, b))

Example 2

# maximum of two numbers

a = 2

b = 4

maximum = max(a, b)

print(maximum)

It will help you....