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, and the syntax behind this is:


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. Below code return the item with the least Numeric Value from a minimumSet.

TIP: Please refer to the Sets 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.

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

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

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.