Python min() FunctionPython Functions


The min() function obtains the element with the lowest value or the element with the lowest value in an iterable.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

a = (1, -1, -2, 3)
x = min(a)
print("min(1, -1, -2, 3):  ", x)

print("min(1, 22, 3, 52):  ", min(1, 22, 3, 52))

Output:

min(1, -1, -2, 3):   -2
min(1, 22, 3, 52):   1

Syntax

min(num1,num2,num3,num4...).

Parameters

The input parameter is a sequence of numbers.

Return Value

It returns the element with the minimum value.

© 2021 Programtips.org, all rights reserved. Privacy Policy | Contact Us