# Python Minimum and Maximum Functions with program examples

In this tutorial, you will learn about python minimum and maximum functions.

## Python Min():

This function used to return the smallest number from the list, tuples and dictionaries.

Syntax: min(arguments,keyvalue)

Integer Example:

Finding lowest value from the integers.

Code:

a=(1,2,3)

b=[4,5,6]

print(“lowest value in tuple”, min(a))

print(“lowest value in list”, min(b))

Output:

lowest value in tuple 1
lowest value in list 4

Float Numbers Example:

Finding lowest value from the float numbers.

Code:

a=(1.7,2.2,3.4)

b=[4.5,5.8,6.9]

print(“lowest float value in tuple”, min(a))

print(“lowest float value in list”, min(b))

Output:

lowest float value in tuple 1.7
lowest float value in list 4.5

Strings: This function return alphabetical order value from strings.

Code:

a=(‘mongo’,’apple’,’banana’)

b=[‘mongo’,’apple’,’banana’]

print(“From string tuple is :”, min(a))

print(“From string list is:”, min(b))

Output:

From string tuple is : apple
From string list is: apple

## Python Max :

This function is used to return maximum value from list, tuples and dictionaries.

Syntax: max(arguments, keyvalue)

Integer:

Finding maximum value from integers

a=(1,2,3)

b=[4,5,6]

print(“maximum value in tuple”, max(a))

print(“maximum value in list”, max(b))

Output:

maximum value in tuple 3
maximum value in list 6

Float Numbers:

Finding maximum value from Float numbers

Code:

a=(1.7,2.2,3.4)

b=[4.5,5.8,6.9]

print(“maximum float value in tuple”, max(a))

print(“maximum float value in list”, max(b))

Output:

maximum float value in tuple 3.4
maximum float value in list 6.9

From Strings:  This function returns a value from strings in alphabetical order. In maximum it reverse the alphabetical order and gives the output.

Code:

a=(‘mongo’,’apple’,’banana’)

b=[‘mongo’,’apple’,’banana’]

print(“From string tuple is :”, max(a))

print(“From string list is:”, max(b))

Output:

From string tuple is : mongo
From string list is: mongo