Question 10
Back to Exercise
What is the output of the following Python program?
def volume(l, w, h=1):
return l * w * h
dims = [2, 3]
opts = {"h": 4}
print(volume(*dims), volume(*dims, **opts), volume(**{"l": 1, "w": 5}))
- A 6 6 5
- B 24 24 5
- C 6 24 5 Correct
- D TypeError
Correct Answer: Option C
*dims passes 2 and 3; **opts passes h=4; the last call passes l and w by keyword with h defaulting to 1.
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!