PCAP Exceptions and File I/O Practice Question
Which TWO of the following are built-in exceptions in Python? (Select exactly 2.)
⚠ Common exam trap
Python Institute often tests candidates by including plausible-sounding exception names like InputError or DataError that mimic real-world patterns but are not part of Python's built-in exception hierarchy, leading candidates to confuse custom or third-party exceptions with standard ones.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
ValueError
ValueError is a built-in exception in Python, raised when a built-in operation or function receives an argument with the correct type but an inappropriate value, such as int('abc'). It is part of Python's standard exception hierarchy and does not require any import.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
InputError
Why it's wrong here
InputError is not part of Python's built-in exception hierarchy. Although some third-party libraries—such as PyInputPlus—define an InputError for invalid user input, the Python Standard Library does not include it. Built-in exceptions are those available without any import, and InputError is not among them, so selecting it as a built-in exception is incorrect.
- ✓
ValueError
Why this is correct
ValueError is a built-in exception and belongs to the Exception hierarchy, directly under Exception (and ultimately under BaseException). It is raised when a function receives an argument of the correct type but an inappropriate value—for example, int('abc') raises ValueError because the string cannot be converted to an integer. This distinguishes it from TypeError, which is for wrong types, and from other built-in exceptions that signal different error conditions.
- ✗
DataError
Why it's wrong here
DataError is not a built-in exception in Python. It does appear in some frameworks and libraries—such as SQLAlchemy's sqlalchemy.exc.DataError for database-related data problems—but the Python Standard Library does not define it. Since the question asks specifically about built-in exceptions that exist without importing any module, DataError cannot be considered correct.
- ✓
FileNotFoundError
Why this is correct
FileNotFoundError is a built-in exception and is a subclass of OSError. It is raised when a file or directory is requested but does not exist at the given path, as in open('nonexistent.txt') when that file is absent. Since its introduction in Python 3.3, it has been the standard exception for missing files and is correctly identified as a built-in exception.
- ✗
CustomError
Why it's wrong here
CustomError is not a built-in exception; it is a placeholder name for user-defined exceptions that developers create by subclassing the Exception class. Python does not provide any exception named CustomError in its Standard Library, and user-defined exceptions are not considered built-in. To be a built-in exception, the name must be defined by the interpreter or Python's standard library without any custom code.
Go deeper
Related to this question
About these practice questions
One of 421 original PCAP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.