Join Regular Classroom : Visit ClassroomTech

Python Tuple – min() Method

It is an inbuilt function in python that returns the min value among all the numbers, if string is involved it returns the alphabetical character with the lowest ASCII value.

Syntax:

min(tuple_name)

Don’t know what is max method in Python Tuple? Read: Python Tuple – max() Method

Example 1:

# Python program to understand min() method in tuple
# www.codewindow.in

s = (85, 55, 47, 98, 32, 65, 62, 54) 
x = min(s)
print(x)

Output:

32

Explanation:

Here the smallest number in the tuple is 32. Hence it returned 32.

Example 2:

# Python program to understand min() method in tuple
# www.codewindow.in

s = ("a", "k", "z", "h") 
x = min(s)
print(x)

Output:

a

Explanation:

Here the ascii value of “a” is the lowest among all other characters. Hence it returned “a”.

Example 3:

# Python program to understand min() method in tuple
# www.codewindow.in

s = ("code", "and", "hustle") 
x = min(s)
print(x)

Output:

and

Explanation:

Here the ascii value of “a” in “and” is the lowest among all other characters. Hence it returned “and”.


You Missed

Also Checkout