Input:<\/strong><\/p>\nGiven Set = {1, 0, 5, 8, 2, 8, 6, 2}<\/pre>\nOutput:<\/strong><\/p>\nThe given set is :\r\n{0, 1, 2, 5, 6, 8}\r\nThe above Given set's minimum value = 0<\/pre>\nExample2:<\/strong><\/p>\nInput:<\/strong><\/p>\nGiven Set = {-1, 5, 3, 10, 16, 0, 3, 2, 5}<\/pre>\nOutput:<\/strong><\/p>\nThe given set is :\r\n{0, 2, 3, 5, 10, 16, -1}\r\nThe above Given set's minimum value = -1<\/pre>\nProgram for Set min() Method in Python<\/h2>\n Set min() Function:<\/strong><\/p>\nThe set min function in Python is used to find the smallest value in a given set.<\/p>\n
Syntax:<\/strong><\/p>\nmin(set_name)<\/pre>\nThe set min function finds the smallest number of items from a given set’s total number of items.<\/p>\n
Approach:<\/strong><\/p>\n\nGive the set as static input and initialize it with some random values.<\/li>\n Store it in a variable.<\/li>\n Print the above-given set.<\/li>\n Apply the min() method to the given set to get the minimum value in the given set.<\/li>\n Store it in another variable.<\/li>\n Print the minimum value in the above-given set.<\/li>\n The Exit of Program.<\/li>\n<\/ul>\nBelow is the implementation:<\/strong><\/p>\n# Give the set as static input and initialize it with some random values.\r\n# Store it in a variable.\r\ngven_set = {1, 0, 5, 8, 2, 8, 6, 2}\r\n# Print the above-given set.\r\nprint(\"The given set is :\")\r\nprint(gven_set)\r\n# Apply min() method to the given set to get the minimum value in the given set.\r\n# Store it in another variable.\r\nminim_val = min(gven_set)\r\n# Print the minimum value in the above-given set.\r\nprint(\"The above Given set's minimum value = \", minim_val)\r\n<\/pre>\nOutput:<\/strong><\/p>\nThe given set is :\r\n{0, 1, 2, 5, 6, 8}\r\nThe above Given set's minimum value = 0<\/pre>\nMethod #2: Using Built-in Functions (User Input)<\/h3>\n Approach:<\/strong><\/p>\n\nGive the set as user input using the set(), map(), input(), and split() functions.<\/li>\n Store it in a variable.<\/li>\n Print the above-given set.<\/li>\n Apply the min() method to the given set to get the minimum value in the given set.<\/li>\n Store it in another variable.<\/li>\n Print the minimum value in the above-given set.<\/li>\n The Exit of Program.<\/li>\n<\/ul>\nBelow is the implementation:<\/strong><\/p>\n# Give the set as user input using the set(), map(), input(), and split() functions.\r\n# Store it in a variable.\r\ngven_set = set(map\r\n(int,input(\"Enter some random values separated by spaces = \").split()))\r\n# Print the above-given set.\r\nprint(\"The given set is :\")\r\nprint(gven_set)\r\n# Apply min() method to the given set to get the minimum value in the given set.\r\n# Store it in another variable.\r\nminim_val = min(gven_set)\r\n# Print the minimum value in the above-given set.\r\nprint(\"The above Given set's minimum value = \", minim_val)<\/pre>\nOutput:<\/strong><\/p>\nEnter some random values separated by spaces = -10 3 4 -25 60 50 3 -10\r\nThe given set is :\r\n{3, 4, -25, 50, -10, 60}\r\nThe above Given set's minimum value = -25<\/pre>\n","protected":false},"excerpt":{"rendered":"In the previous article, we have discussed Python oct() Function with Examples Python set: 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 …<\/p>\n
Python Program for Set min() Method<\/span> Read More »<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[5],"tags":[],"yoast_head":"\nPython Program for Set min() Method - Python Programs<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n