← 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?
- A.A comment that describes a function
- B.A function that takes a function and returns a new function with extra behaviour
- C.A special kind of class attribute
- 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 →