🎙 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 1 of 10

What is a decorator in Python?

What is a decorator in Python?

  1. A.A comment that describes a function
  2. B.A function that takes a function and returns a new function with extra behaviour
  3. C.A special kind of class attribute
  4. D.A way to make a function run faster automatically
Answer & explanation

Correct answer: A function that takes a function and returns a new function with extra behaviour

A decorator wraps a function; @deco is shorthand for f = deco(f).

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 →