Finding Extremes in a List

Write a Python function that accepts a list of numbers and returns a tuple containing the smallest and the largest number in the list.

Example 1:

Input: [1,2,3,4,5] 
Output: (1,5)

Example 2:

Input: [10,20,30,40,50] 
Output: (10,50)

Use Python’s built-in min() and max() functions to find the smallest and largest numbers respectively.

def find_extremes(numbers):
    return min(numbers), max(numbers)

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!