โ† 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. You import a module and get `ModuleNotFoundError`. The module is installed. What should you investigate first?

    Answer: Whether you are running Python from the correct virtual environment

    Installing a package in one environment (e.g., system Python) while running a different environment (virtualenv) is the most common cause.

  2. Two threads update a shared counter without synchronization and produce incorrect results. What is the standard Python fix?

    Answer: Use threading.Lock() to protect the counter update

    A `Lock` ensures only one thread modifies the counter at a time, preventing race conditions.

  3. You call a list's `.sort()` method and then try to use the returned value in a chain. The result is `None`. Why?

    Answer: list.sort() sorts in place and returns None; use sorted() for a new sorted list

    In-place methods like `list.sort()` modify the object and return `None` by design; `sorted()` returns a new list.

  4. A script using `multiprocessing` hangs indefinitely. What is the most common cause?

    Answer: The `if __name__ == '__main__':` guard is missing on Windows

    On Windows, `multiprocessing` requires the `if __name__ == '__main__':` guard to prevent child processes from re-spawning endlessly.

  5. You use `logging.debug('value is %s', val)` but see no output. What is the most likely reason?

    Answer: The root logger's level is set to WARNING by default, filtering out DEBUG messages

    Python's root logger defaults to WARNING level, so DEBUG and INFO messages are silently discarded without configuration.

  6. A `ValueError: too many values to unpack` occurs on `a, b = my_list`. What does this mean?

    Answer: my_list has more than 2 elements and cannot be unpacked into exactly 2 variables

    Tuple/list unpacking requires the number of variables on the left to match the number of elements exactly.

  7. Your `datetime` arithmetic gives unexpected results when mixing naive and timezone-aware objects. What is the fix?

    Answer: Make all datetime objects timezone-aware using datetime.timezone.utc or a library like pytz

    Python raises `TypeError` when comparing naive and aware datetimes; making all objects timezone-aware eliminates the ambiguity.