min

Full name
min
Library
Built-in
Syntax

min(iterable, *[, key, default])

min(arg1, arg2, *args[, key])

Description

The min function returns the minimum value of an iterable, or the minimum value of two or more arguments. If only one positional argument is specified, it must be an iterable and the function will return its lowest element. If two or more positional arguments are included, the function will return the lowest argument. If multiple minimum values are found, the first one found is returned.

Parameters
  • iterable: Iterable whose lowest value we want to obtain.
  • key: (Optional) argument that specifies the single input argument function to use to determine the lowest value.
  • default: Value to return if the iterable is empty. If the iterable is empty and this argument is not specified, the function returns an error of type ValueError.
  • arg1, arg2, *args: Values to extract the lowest from.
Examples

This example calculates the minimum value of an iterator:

m = [8, 4, 2, 7, 3]
print(min(m))

Min function. Example of use

 

In this other example we include multiple values as arguments:

print(min("k", "f", "c", "h"))

Min function. Example of use

 

Submitted by admin on Sun, 01/20/2019 - 18:09