Certified Professional in Python Programming (PCPP-32-101) — Question 31
Select the true statement about the __name__ attribute.
Answer options
- A. __name__ is a special attribute, which is inherent for both classes and instances, and it contains information about the class to which a class instance belongs.
- B. __name__ is a special attribute, which is inherent for both classes and instances, and it contains a dictionary of object attributes.
- C. __name__ is a special attribute, which is inherent for classes, and it contains information about the class to which a class instance belongs.
- D. __name__ is a special attribute, which is inherent for classes, and it contains the name of a class.
Correct answer: D
Explanation
The correct answer is D because the __name__ attribute is specifically tied to classes and indicates the name of the class itself. Options A and B incorrectly state that __name__ applies to instances, while C does not mention that __name__ provides the class name specifically.