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
A Python script raises `RecursionError: maximum recursion depth exceeded`. What is the most appropriate fix?
Answer: Add a base case to terminate recursion
A missing or unreachable base case is the root cause of infinite recursion; adding one stops the runaway calls.
You call `int('3.14')` and get a `ValueError`. How do you convert the string '3.14' to an integer correctly?
Answer: int(float('3.14'))
`int()` cannot parse a string containing a decimal point, so you must first convert to float then to int.
A `KeyError` occurs when accessing `my_dict['name']`. Which approach gracefully handles a missing key?
Answer: my_dict.get('name', 'default')
`dict.get(key, default)` returns the default value instead of raising `KeyError` when the key is absent.
Your script produces `IndentationError: unexpected indent`. What is the most likely cause?
Answer: Mixing tabs and spaces in the same block
Python treats tabs and spaces as different characters, so mixing them causes inconsistent indentation levels.
A `TypeError: 'NoneType' object is not subscriptable` appears. What likely happened?
Answer: A function returned None and the result was indexed with []
This error means you tried to use subscript notation on a None value, often from a function that returns nothing explicitly.
The `pdb` debugger is running and you want to step INTO the next function call. Which command do you use?
Answer: s
`s` (step) enters the function being called, whereas `n` (next) executes it and stays in the current frame.
You see `MemoryError` while building a large list. Which technique reduces memory usage most effectively?
Answer: Use a generator expression instead of a list comprehension
Generators yield items one at a time and never store the entire sequence in memory, unlike list comprehensions.