Question 6
Back to Exercise
What is the output of the following Python program?
def add_a(f):
return lambda: f() + "a"
def add_b(f):
return lambda: f() + "b"
@add_a
@add_b
def base():
return "x"
print(base())
- A xba Correct
- B xab
- C abx
- D bax
Correct Answer: Option A
base = add_a(add_b(base)): add_b appends "b" to "x" first, then add_a appends "a".
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!