Questions: Debugging Basics

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A Python program crashes with 'IndexError: list index out of range' on line 47. A student goes directly to line 47 and fixes the index access, but the bug persists. What is the most likely explanation?

AThe student forgot to save the file before re-running
BIndexError cannot be fixed by changing the index — a different data structure is needed
CThe error message is unreliable and the real crash site is elsewhere
DLine 47 is where bad data arrived and crashed, but the bug that created the bad data is earlier in the code
Question 2 Multiple Choice

A programmer's function produces wrong output. She adds a print statement just before the function returns and sees the value looks correct at that point. What should she conclude?

AThe function's algorithm is definitely wrong and needs to be rewritten
BThe print confirms the bug is in this function; she should add more prints inside it
CThe function appears correct; the bug is likely in how the return value is used downstream
DPrint debugging is unreliable and she should switch to a debugger immediately
Question 3 True / False

When reading a Python stack trace, the most useful information about the root cause is usually found on the last line printed.

TTrue
FFalse
Question 4 True / False

A logic error is harder to detect than a syntax error because the program runs to completion and only reveals itself through wrong output, not a crash.

TTrue
FFalse
Question 5 Short Answer

Why is forming a hypothesis before changing code the habit that separates effective debugging from ineffective debugging?

Think about your answer, then reveal below.