{"id":23931,"date":"2021-10-14T09:13:49","date_gmt":"2021-10-14T03:43:49","guid":{"rendered":"https:\/\/python-programs.com\/?p=23931"},"modified":"2021-11-03T22:36:23","modified_gmt":"2021-11-03T17:06:23","slug":"python-program-for-set-min-method","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-set-min-method\/","title":{"rendered":"Python Program for Set min() Method"},"content":{"rendered":"

In the previous article, we have discussed Python oct() Function with Examples<\/a>
\nPython set:<\/strong><\/p>\n

Python set is a list of items that are not ordered. \u2013 Each element in the set must be unique and immutable, and duplicate elements are removed from the sets. Sets are mutable, which means they can be changed after they have been created.<\/p>\n

The elements of the set, unlike other Python sets, do not have an index, which means we cannot access any element of the set directly using the index. To get the list of elements, we can either print them all at once or loop them through the collection.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Set = {1, 0, 5, 8, 2, 8, 6, 2}<\/pre>\n

Output:<\/strong><\/p>\n

The given set is :\r\n{0, 1, 2, 5, 6, 8}\r\nThe above Given set's minimum value =  0<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Set = {-1, 5, 3, 10, 16, 0, 3, 2, 5}<\/pre>\n

Output:<\/strong><\/p>\n

The given set is :\r\n{0, 2, 3, 5, 10, 16, -1}\r\nThe above Given set's minimum value =  -1<\/pre>\n

Program for Set min() Method in Python<\/h2>\n

Set min() Function:<\/strong><\/p>\n

The set min function in Python is used to find the smallest value in a given set.<\/p>\n

Syntax:<\/strong><\/p>\n

min(set_name)<\/pre>\n

The set min function finds the smallest number of items from a given set’s total number of items.<\/p>\n

Method #1: Using Built-in Functions (Static Input)<\/h3>\n

Approach:<\/strong><\/p>\n