In this article, we are going to learn all about the Python min function to find the lowest value from the iterable ( list, tuple, and set ) and multiple values. If you have a large iterable object, Then this will best function to find the lowest value from them.
In the previous tutorial, we have seen all about the Python max() function to find the highest value from the iterable.
Python min() Function
Python min function is a Python built-in function that returns the lowest value from the iterable. If the value is a string, Then an alphabetical comparison will be done.
Syntax
The syntax of min function in python is:-
min(n1, n2, n3)
or
min(iterable)
Parameter
n1, n2, n3 represent the numbers to compare.
or
iterable:- An any python iterable to compare the items.
Return Value
The return value of min function in Python is the lowest value from the iterable or total numbers.
Python min example
Here we will see some examples to understand python min function.
Example 1:
#Find lowest value from the numbers.
result = min(12, 23, 43, 10)
print(result)
Output will be:- 10
Example 2:
#Return the name with lowest value, order alphabetically.
result = min('Python', 'Java', 'PHP', 'HTML')
print(result)
Output will be:- PHP
Example 3:
#Find highest value from the list iterable.
my_list = [12, 10, 23, 40, 100]
print(min(my_list))
Output will be:- 10
Conclusion
So here we have learned how to find the lowest value from the iterable using the python min function.
You can use multiple values inside the min function separated by a comma to find the lowest value from them instead of iterable.
If you like this article, please share and keep visiting for python built-in functions tutorials.
Python built-in functions
For more information:- Click Here