Question 7
Back to Exercise
What is the output of the following Python program?
def stats(nums):
return min(nums), max(nums), sum(nums) / len(nums)
r = stats([2, 8, 5])
print(r, type(r).__name__)
lo, hi, avg = r
print(lo, hi, avg)
- A [2, 8, 5.0] list 2 8 5.0
- B (2, 8, 5.0) tuple 2 8 5.0 Correct
- C 2 8 5.0 tuple 2 8 5.0
- D (2, 8, 5) tuple 2 8 5
Correct Answer: Option B
The return statement packs one tuple. / always gives a float, so the average is 5.0.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!