09-Dec-2021
.
Admin
Hello Friends,
I would like to share with you how to use max() function in python. we will learn about the Python max() function. I am going show you python max() function example.
Python max() function returns the largest item in an iterable or the largest of two or more arguments. The max() function returns the item with the highest value.
Here I will give example for use of max() function using python. So let's see the below example:
Syntax:
max (num1, num2, num3, ...)
Example : 1
maxNum = max(1,51,16,61,9,10,15)
print(maxNum)
Output:
61
Example : 2
numList = [5, 16, 151, 850, 456, 115, 444, 989, 102]
print("The Max Value in List, ", max(numList))
Output:
The Max Value in List, 989
Example : 3
color = ['orange', 'pink', 'black', 'red']
print("The Max color is : ", max(color))
Output:
The Max color is : red
Example : 4
list = [[6, 8], [1, 2], [5, 4],[8,9]]
print("The Maximum Value : ", max(list))
Output:
The Maximum Value : [8, 9]
It will help you....
#Python