What is the output of the following Python code snippet?
class A:
def __init__(self): self.x = 1
print(A().__dict__)
def __init__(self): self.x = 1
print(A().__dict__)
Correct answer
C. {'x': 1}
5 views
C. {'x': 1}
5 views
Instance attributes are stored in the instance __dict__.
Asked in: Python Interview OOP
https://docs.python.org/3/tutorial/classes.htmlNot sure why the answer is C? Ask here and get an explanation.