🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Python Decorators: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What is a decorator in Python?
  2. Q2. @timer above def load(): is the same as which line?
  3. Q3. What does this print? (code)
  4. Q4. What does this print? (code)
  5. Q5. Why should a wrapper use args, kwargs?
  6. Q6. What does @functools.wraps(func) do?
  7. Q7. How many nested functions does a decorator with arguments, like @repeat(3), usually have?
  8. Q8. What does this print? (code)
  9. Q9. Which standard-library decorator remembers results so repeated calls are fast?
  10. Q10. Which of these is a typical real use of decorators?