Q12
What is the purpose of the __slots__ attribute in Python classes?
A.
To define a class as a singleton
B.
To restrict the attributes that can be added to instances
AnswerC.
To define class methods
D.
To define class attributes
Answer: Option B
Solution
Answer: Option B
Solution:
The __slots__ attribute restricts the attributes that can be added to instances, optimizing memory usage.