search

What is the use of the "min" and "max" functions in Python?

The **min** and **max** functions in Python are used to determine the minimum and maximum values, respectively, in a given sequence or iterable object such as a list, tuple, or set. They are built-in functions in Python and can be used with any iterable that contains comparable elements.

Here's an example of how to use the **min** function:

numbers = [1, 2, 3, 4, 5]
minimum = min(numbers)
print(minimum) # Output: 1

Similarly, you can use the **max** function to find the maximum value:

numbers = [1, 2, 3, 4, 5]
maximum = max(numbers)
print(maximum) # Output: 5

Related Questions You Might Be Interested