← Quiz: Python Decorators: all 10 questions
Quiz: Python Decorators · Question 8 of 10
What does this print? (code)
What does this print?
def a(f):
return lambda: "A" + f()
def b(f):
return lambda: "B" + f()
@a
@b
def x():
return "x"
print(x())
- A.BAx
- B.ABx
- C.xAB
- D.Ax
Answer & explanation
Correct answer: ABx
x = a(b(x)): the outer a adds "A" in front of what b's version returns ("Bx").
Can you get the rest right without peeking?
Take the timed Quiz: Python Decorators quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →