Courseiva
Exceptions and File I/O →easyMultiple Select

PCAP Exceptions and File I/O Practice Question

Which TWO of the following are built-in Python exceptions?

⚠ Common exam trap

Python Institute often tests the distinction between built-in exceptions and user-defined or non-existent exceptions, and the trap here is that candidates may confuse InputError or FileReadError with real built-in exceptions like EOFError or OSError, or assume that any error related to input or files must be a built-in exception.

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 (C) is a built-in Python exception that is raised when a built-in operation or function receives an argument with the correct type but an inappropriate value, such as int('abc'). FileNotFoundError (D) is a built-in exception in Python 3, raised when a file or directory is requested but does not exist, commonly encountered during file I/O operations like open().

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    CustomException

    Why it's wrong here

    CustomException is not a built-in Python exception; it represents a placeholder for user-defined exception classes. Developers typically create such classes by subclassing the built-in `Exception` base class (or a subclass like `RuntimeError`) to handle application-specific error conditions. The Python standard library does not include any class named `CustomException`, so seeing it in code signals a custom, project-specific definition.

  • ✗

    InputError

    Why it's wrong here

    InputError is not a built-in exception in Python's standard library. The built-in `ValueError` is the closest match, raised when a function receives an argument of the correct type but an inappropriate value, while `TypeError` handles type mismatches. Although some third-party libraries or frameworks define an `InputError` class, the Python language itself does not provide one, so referring to it as a built-in exception is incorrect.

  • ✓

    ValueError

    Why this is correct

    ValueError is a built-in exception in Python, defined in the `builtins` module and raised when a function receives an argument of the correct type but an invalid value—for example, `int('abc')` or `math.sqrt(-1)`. It is deliberately distinct from `TypeError`, which covers type mismatches, allowing programmers to catch value-specific errors cleanly. As a built-in, it is always available without any import and is part of the core exception hierarchy.

  • ✓

    FileNotFoundError

    Why this is correct

    FileNotFoundError is a built-in exception in Python, introduced in version 3.3 as a subclass of `OSError` and raised when a file or directory is requested but does not exist on the filesystem. It carries an `errno` attribute (typically `ENOENT`) and a `filename` attribute, making it useful for precise error handling in I/O operations. Because it inherits from `OSError`, a bare `except OSError` will also catch it, but catching the specific subclass allows more targeted recovery.

  • ✗

    FileReadError

    Why it's wrong here

    FileReadError is not a built-in exception in Python; the standard library includes `OSError`, `IOError` (an alias of `OSError`), and more specific subclasses like `FileNotFoundError` and `PermissionError`, but no `FileReadError`. This name might appear in custom code, third-party libraries, or other programming languages, but it is not defined in Python's `builtins` or `exceptions` modules. Using it without a custom definition raises a `NameError`, so it cannot be considered a built-in exception.

About these practice questions

This PCAP question is part of Courseiva's 421-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.