Finding Maximum and Minimum Value in a Set

Tags: max, min, Set

Write a Python program to find the maximum and minimum value in a set. The function should return a tuple containing the maximum and minimum value.

Example 1:

Input: {1, 2, 3, 4, 5} 
Output: (5, 1)

Example 2:

Input: {25, 50, 75, 100} 
Output: (100, 25)

Use the built-in functions max() and min() to find the maximum and minimum value in a set.

def find_max_min(set1):
    return max(set1), min(set1)

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!