← Quiz: Encapsulation and Abstraction: all 10 questions
Quiz: Encapsulation and Abstraction · Question 7 of 10
In Python, what does self.balance (double underscore) do?
In Python, what does self.__balance (double underscore) do?
- A.Makes the attribute truly private and impossible to reach
- B.Triggers name mangling, so outside code writing
acc.__balancecreates a different attribute - C.Makes the attribute read-only
- D.Deletes the attribute after use
Answer & explanation
Correct answer: Triggers name mangling, so outside code writing acc.__balance creates a different attribute
Python has conventions and name mangling, not true private variables.
Can you get the rest right without peeking?
Take the timed Quiz: Encapsulation and Abstraction quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →