How to Use min() Function in PythonPython Basics


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.

© 2024 Learnwithgpt.org, all rights reserved. Privacy Policy | Contact Us