min()

Math

Returns the smallest item in an iterable or the smallest of two or more arguments.

Signature

min(iterable, *, key, default)

Returns

any

Example

print(min([3, 1, 4, 1, 5]))  # 1
print(min('hello'))           # 'e'
people = [('Alice', 30), ('Bob', 25)]
print(min(people, key=lambda p: p[1]))  # ('Bob', 25)

About min()

min is a Python math function with the signature min(iterable, *, key, default). Returns the smallest item in an iterable or the smallest of two or more arguments. It returns a value of type any.

Python provides a rich set of built-in functions and standard library modules that cover common programming tasks. Understanding these functions helps you write more idiomatic, efficient Python code. The minfunction is commonly used in data processing, web development, scripting, and automation tasks.

When working with min(), consider edge cases like empty inputs, None values, and type mismatches. Python's duck typing means many built-in functions work with any object that implements the required protocol (e.g., __len__ for len(), __iter__ for iteration). This flexibility is a key strength of Python's design philosophy.

Related Functions