{"id":23901,"date":"2021-10-05T20:32:01","date_gmt":"2021-10-05T15:02:01","guid":{"rendered":"https:\/\/python-programs.com\/?p=23901"},"modified":"2021-11-22T18:33:24","modified_gmt":"2021-11-22T13:03:24","slug":"python-program-for-set-max-method","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-set-max-method\/","title":{"rendered":"Python Program for Set max() Method"},"content":{"rendered":"

Python 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 = {20, 40, 50, 10, 20, 60, 50}<\/pre>\n

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

The given set is :\r\n{40, 10, 50, 20, 60}\r\nThe above Given set's maximum value =  60<\/pre>\n

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

Here 60 is the maximum value in the given set . so, the maximum value 60 is printed by using the max() method.<\/pre>\n

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

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

Given Set = {1, 3, 5, 20, 60, 90}<\/pre>\n

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

The given set is :\r\n{1, 3, 5, 20, 90, 60}\r\nThe above Given set's maximum value =  90<\/pre>\n

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

Here 90 is the maximum value in the given set . so, the maximum value 90 is printed by using the max() method.<\/pre>\n

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