Consider the following code which would set the hour of a Time object to an invalid value. wake_up._hour = 100
Which of the following statements is false?
A) Rather than _hour, we can name the attribute __hour with two leading underscores. This convention indicates that __hour is "private" and should not be accessible to the class's xe "client of a class"clients.
B) To help prevent clients from accessing "private" attributes, Python renames them by preceding the attribute name with _ClassName, as in _Time__hour. This is called xe "name mangling"name mangling.
C) If you try to assign to __hour, as in
Wake_up.__hour = 100
Python raises a ValueError, indicating that the class does not have an __hour attribute.
D) IPython does not show attributes with one or two leading underscores when you try to auto-complete an expression like
Wake_up.
By pressing Tab. Only attributes that are part of the wake_up object's "public" interface are displayed in the IPython auto-completion list.
Correct Answer:
Verified
Q28: Which of the following statements is false?
A)
Q29: Which of the following statements is false?
A)
Q30: Consider the following code from our class
Q31: Which of the following statements a), b)
Q32: A read-only property has _.
A) only a
Q34: Properties are implemented as _, so they
Q35: The following code and traceback shows that
Q36: Which of the following statements a), b)
Q37: Class Time's properties and methods define the
Q38: Which of the following statements a), b)
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents