← All POC Flashcard Decks

Troubleshooting & Problem Resolution Flashcards

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

Read the first 7 Troubleshooting & Problem Resolution flashcards as text
  1. A `FileNotFoundError` is raised when opening a file. Which debugging step should you take first?

    Answer: Print or log the exact file path being used at runtime

    Runtime paths often differ from what developers assume; printing the resolved path immediately reveals mismatches.

  2. You catch an exception with `except Exception as e:` but lose the original traceback. How do you re-raise it with the full traceback intact?

    Answer: Use `raise` with no arguments inside the except block

    A bare `raise` inside an except block re-raises the current exception preserving its original traceback.

  3. Your unit test passes locally but fails in CI because a file path uses backslashes. What is the portable fix?

    Answer: Use os.path.join() or pathlib.Path() to construct paths

    `os.path.join()` and `pathlib.Path` use the correct separator for the current OS, making paths platform-independent.

  4. A `UnicodeDecodeError` occurs when reading a file. Which argument to `open()` most likely fixes it?

    Answer: encoding='utf-8'

    Specifying the correct encoding (commonly UTF-8) tells Python how to decode the raw bytes in the file.

  5. You have an infinite loop in a running Python script. Which is the quickest way to stop it without killing the terminal?

    Answer: Press Ctrl+C to send a KeyboardInterrupt

    Ctrl+C sends SIGINT to the process, which Python converts to a `KeyboardInterrupt` and stops the loop.

  6. After refactoring, you get `AttributeError: module 'mymodule' has no attribute 'helper'`. What should you check first?

    Answer: Whether the function was renamed or deleted in mymodule.py

    The error directly states the attribute is missing, so verifying the module's current contents is the logical first step.

  7. A script occasionally raises `ZeroDivisionError` depending on input data. What is the best defensive approach?

    Answer: Validate the divisor before dividing and handle the zero case explicitly

    Checking preconditions (guard clauses) prevents the error from occurring rather than catching it after the fact.