🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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())
  1. A.BAx
  2. B.ABx
  3. C.xAB
  4. 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 →