Python set min

Python set min function is used to find the minimum value within a given set. In this section, we discuss how to use this set min or minimum function, and the syntax behind this is:

min(set_Name)

Python set min Example

The set min function helps you to find the minimum items from the total number of items in a given set. The below code returns the item with the least Numeric Value from a minimumSet.

TIP: Please refer to the Sets and set functions articles in Python.

minimumSet = {15, 25, 35, 45, 55}
print("\nOld Set Items = ", minimumSet)

print("Minimum Value in a Set = ", min(minimumSet))

Old Set Items =  {35, 55, 25, 45, 15}
Minimum Value in a Set =  15

Example 2

In this example, we declared a string set. Next, we used this method on the string. Here, the min function returns the word that starts with the least Alphabet. Please refer to the set add and set max function article.

minimumFruitSet = {'mango', 'kiwi', 'apple', 'orange', 'banana'}
print("\nOld Set Items = ", minimumFruitSet)

# Minimum
print("Minimum Value in a Set = ", min(minimumFruitSet))
set min method Example