Python set min Method

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. The syntax behind this set min function is:


Python set min Example 1

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

TIP: Please refer to the Sets in Python.

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

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

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

Python minimum set item Example 2

In this example, we declared a string set. Next, we used this set min function on the string set. Here, min function returns the word starts with the least Alphabet.

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

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