#550 · Functions · Beginner · 30 XP · about 4 min
A function can hand back several values at once by returning a tuple. Write summary(nums) that returns a tuple (smallest, largest, average) for a list of numbers, with the average rounded to 2 decimal places using round(value, 2).
Whoever calls the function can then unpack the three values into three names: low, high, avg = summary(marks). The list always has at least one number.
summary([4, 8, 6]) # returns (4, 8, 6.0) summary([3, 1, 2, 2]) # returns (1, 3, 2.0) summary([10, 0, 5, 5, 1]) # returns (0, 10, 4.2)
First solves only, ranked by stars and then time.