ExamVeda
Login
Home
21
How can you remove a decorator from a function in Python?
Discuss
Answer & Solution
Answer: Option C
Solution:
You can remove a decorator by removing the @decorator syntax from the function.
22
What is a memoization decorator used for?
Discuss
Answer & Solution
Answer: Option C
Solution:
A memoization decorator is used to cache the results of a function to improve performance.
23
What is the purpose of the @lru_cache decorator in Python?
Discuss
Answer & Solution
Answer: Option C
Solution:
The @lru_cache decorator is used to cache function results with a limited size using the Least Recently Used strategy.
24
How does the @contextmanager decorator facilitate context management?
Discuss
Answer & Solution
Answer: Option C
Solution:
The @contextmanager decorator allows a function to act as a context manager with the with statement.
25
What is the purpose of the @dataclass decorator in Python?
Discuss
Answer & Solution
Answer: Option D
Solution:
The @dataclass decorator simplifies the creation of classes for storing and manipulating data.