
Python InstitutePCPP1 - Certified Professional Python Programmer 1
Domain 1Objective 8
PCPP-32-101 1.8 Apply Subclassing of Built-In Classes PCPP-32-1 Practice Questions (Page 3)
Part of the Advanced Object-Oriented Programming domain, which accounts for 35% of the PCPP-32-1 exam. Python Institute does not publish an official question count, but from its 65-minute exam (~25–45 total, ~9–16 in this domain), expect 1–1 from this objective — we provide 21 practice questions to prepare you well beyond it. (estimate)
21questions here
5free pages
5concepts
35%of the exam
Questions 11–15
- 11
A developer creates a subclass of str that overrides __eq__ to compare strings case-insensitively. They write: class CaseInsensitiveStr(str): def __eq__(self, other): return self.lower() == other.lower() They test CaseInsensitiveStr('Hello') == 'hello' and it returns True. However, when they test 'hello' == CaseInsensitiveStr('Hello'), it returns False. Why?
Select an answer first - 12
A developer creates a subclass of list that overrides __setitem__ to validate that the value is an integer. They also override append() to use the same validation. When they use the .insert() method with a non-integer value, no error is raised. Why?
Select an answer first - 13
A developer needs a string type that automatically strips whitespace from both ends when created. They write: class CleanString(str): def __new__(cls, value): return super().__new__(cls, value.strip()) They test CleanString(' hello ') and it works. However, when they call CleanString(' hello ').upper(), the result is 'HELLO ' with trailing spaces. Why?
Select an answer first - 14
A developer creates a subclass of list that overrides __getitem__ to return a default value when the index is out of range. They write: class SafeList(list): def __getitem__(self, index): try: return super().__getitem__(index) except IndexError: return None They test it with SafeList([1,2,3])[5] and it returns None. However, when they iterate over the list with a for loop, it raises IndexError. Why?
Select an answer first - 15
A developer needs a list that rejects duplicate elements, similar to a set but preserving insertion order. They subclass list and override append() to check for duplicates before calling super().append(). They test it and it works. However, when they use the .extend() method with a list containing duplicates, duplicates are added. Why?
Select an answer first
Finished these 5 questions?
Review the revealed explanations, or continue through the curriculum.
Free Basic Practice is a study aid with revealable answers — not a scored exam. Examers.io is independent and not affiliated with or endorsed by Python Institute. “PCPP-32-1” is a trademark of its owner, used for identification only.