2.3 - Decorators with Parameters
Enroll to start learning
You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Practice Questions
Test your understanding with targeted questions
What purpose does a parameterized decorator serve?
💡 Hint: Think of how you might change a function's action based on different inputs.
Give an example of a scenario where a parameterized decorator would be useful.
💡 Hint: Consider cases where repetitive action may be needed.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What is a parameterized decorator?
💡 Hint: Think about how parameters change the behavior of functions.
True or False: A parameterized decorator can only have one parameter.
💡 Hint: Think about functions; can they have multiple inputs?
1 more question available
Challenge Problems
Push your limits with advanced challenges
Create a parameterized decorator called timing that measures and prints the time taken to execute a function.
💡 Hint: How can you measure the start and end time around the function call?
Write a parameterized decorator that adds a custom greeting to the output of any function it wraps.
💡 Hint: What do you need to append to the function's output?
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.