Python_Institute
PCPP-32-101 · Question #67
PCPP-32-101 Question #67: Real Exam Question with Answer & Explanation
The correct answer is C. Use a class attribute to track the last assigned ID.. See the full explanation below for the reasoning.
Question
You are developing a class where instances need to maintain a unique ID. Which approach would ensure this without duplicating IDs?
Options
- AGenerate IDs using hash() on the object.
- BDefine init and assign IDs randomly.
- CUse a class attribute to track the last assigned ID.
- DUse a dictionary with IDs as keys.
Community Discussion
No community discussion yet for this question.