Problem Statement
What is a key effect of defining __slots__ in a class?
Explanation
__slots__ defines a fixed set of attributes and usually removes the instance dictionary. This lowers memory and can slightly speed attribute access.
It trades flexibility: you cannot add new attributes not declared in slots unless you keep a dict too.
Code Solution
SolutionRead Only
class Light:
__slots__ = ('on',)
def __init__(self): self.on=False