
Python InstitutePCAP - Certified Associate Python Programmer
Domain 2Objective 2
PCAP-31-03 2.2 Extend the Exceptions Hierarchy with Self-Defined Exceptions PCAP-31 Practice Questions (Page 2)
Part of the Exceptions domain, which accounts for 14% of the PCAP-31 exam. Python Institute does not publish an official question count, but from its 65-minute exam (~25–45 total, ~4–6 in this domain), expect 2–3 from this objective — we provide 12 practice questions to prepare you well beyond it. (estimate)
12questions here
3free pages
6concepts
14%of the exam
Questions 6–10
- 6
Consider the following custom exception class: class ConfigError(Exception): def __init__(self, key, message): self.key = key self.message = message What does the __init__ method accomplish in this class?
Select an answer first - 7
Which code snippet correctly defines a custom exception class named ValidationError?
Select an answer first - 8
A developer is building a library that validates user input for a configuration file. They need to raise a specific error when a required key is missing, but they also want code that catches any configuration-related problem to work. Which class definition should they use?
Select an answer first - 9
A developer is designing an exception hierarchy for a network library. They have a base NetworkError and subclasses ConnectionError and TimeoutError. A function raises TimeoutError. Which except clause will catch it but NOT ConnectionError?
Select an answer first - 10
A developer is writing a custom exception for a payment gateway. They want the exception to be catchable by a generic except Exception handler, but also want to be able to catch it specifically. Which class definition is appropriate?
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. “PCAP-31” is a trademark of its owner, used for identification only.