← All PCAP Flashcard Decks

Exception Handling Flashcards

6 cards from real PCAP practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 6 Exception Handling flashcards as text
  1. Which exception is raised when dividing by zero in Python?

    Answer: ZeroDivisionError

    `ZeroDivisionError` is raised when attempting to divide a number by zero.

  2. Which exception is raised when accessing an index that does not exist in a list?

    Answer: IndexError

    `IndexError` is raised when a sequence subscript is out of range.

  3. Which exception is raised when a dictionary key is not found?

    Answer: KeyError

    `KeyError` is raised when a mapping key is not found in the dictionary.

  4. How do you create a custom exception class in Python?

    Answer: Inherit from Exception

    Custom exceptions are created by subclassing `Exception` or one of its subclasses.

  5. What does `except (TypeError, ValueError):` do?

    Answer: Catches either TypeError or ValueError

    A tuple of exception types in an except clause catches any of those exception types.

  6. Which exception is raised when a variable is used before it is assigned?

    Answer: NameError

    `NameError` is raised when a local or global name is not found.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy

Sources & references

Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy

  1. pythoninstitute.org — Eligibility, fees, retake fee, retake policy, score release, time limit, score validity · verified Nov 2026
  2. home.pearsonvue.com — Test delivery · verified Nov 2026