Question 12
Back to Exercise
What is the output of the following Python program?
def sq(x):
return x * x
f = sq
print(f(4), f.__name__, list(map(sq, [1, 2, 3])))
- A 16 f [1, 4, 9]
- B sq 16 [1, 4, 9]
- C TypeError
- D 16 sq [1, 4, 9] Correct
Correct Answer: Option D
f is just another name for the same function object, whose __name__ is still "sq".
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!