Return Several Values
Completed
Write stats(nums) that returns the minimum, maximum and mean as a tuple. Print them on one line, the mean with 2 decimals.
Input
One line of integers.
Output
min max mean
Example
Input
4 8 15 16 23 42
Output
4 42 18.00
Editor
Python
Hints
return a, b, c actually returns one tuple.
Unpack it at the call site.
Solution explanation
Returning a tuple and unpacking it is how Python functions "return several values".
Show solution
def stats(nums):
return min(nums), max(nums), sum(nums) / len(nums)
low, high, mean = stats(list(map(int, input().split())))
print(f"{low} {high} {mean:.2f}")