- A To identify the variable
- B It confuses the interpreter
- C It indicates a private variable of a class
- D None of these
- Share this MCQ
Answer:
C
Share this MCQ
In Python, there is no concept of private variables like there is in some other programming languages.
However, a convention that is often used to indicate that a member of a class should not be accessed directly from outside the class is to begin the name of the variable with an underscore (e.g., _private_var).
This is just a convention, though, and Python does not enforce any restrictions on accessing variables that are named with an underscore.
It is up to the programmer to respect this convention and avoid accessing such variables directly from outside the class.
Share this MCQ