Member-only story

Python: Min() Function Tutorial

Jesse L
2 min readDec 25, 2021

--

Hi everyone, welcome back. Today, we will be going over the min() function in Python and see how it works. The min() function is a built in function and it will return the lowest value within an iterable. With this introduction our of the way, let’s get into it.

Min() Function

Let’s see how the min() function works:

list = [1, 2, 3]
print(min(list))
Output:
1

As we can see in the example above, we created a list with 3 values and printed the minimum value within the list. Our output contains a ‘1’ which is our lowest value.

The min() function works with strings as well, which will return the first item in alphabetical order. Let’s see an example:

list = ["a", "b", "c"]
print(min(list))
Output:
a

Additional Examples

Min() function being used with a tuple:

tuple = [1, 2, 3]
print(min(tuple))
Output:
1

Min() function being used with a set:

set = {1, 2, 3}
print(min(set))
Output:
1

Min() function being used with a dictionary:

dictionary = {1 : "one", 2 : "two", 3 : "three"}
print(min(dictionary))
Output:
1

Conclusion

This is it for the min() function example. It’s a fairly straight forward function that returns the lowest value within a given iterable object. I hope this helps. Thanks for reading.

--

--

Jesse L
Jesse L

Written by Jesse L

Hi, I'm a passionate technology enthusiast and lifelong learner. Beyond my technical pursuits, I'm also passionate about sharing my enthusiasm with others.

No responses yet