Computer Science I / Debugging Logic and State
Practice question · Sort into groups

Sort each debugging action by whether it reasons from evidence or merely guesses.

Groups: Reasoning from evidence · Debugging by guessing

Hints
  1. Ask of each move: does it produce an observation, or only a change?
  2. A change that might hide a symptom without revealing why is a guess.
Show the answer

Reasoning from evidence: Print the variable's value at the suspect line, Set a breakpoint and step through, watching the state

Debugging by guessing: Change a comparison because it feels wrong, then re-run, Rewrite the function from scratch and hope the bug vanishes

Why

Printing values, stepping through, and narrowing the good-to-bad gap all produce evidence; changing code on a hunch, rewriting blindly, and adding delays produce none. The danger of the guessing moves is that they can hide a symptom while leaving the real cause in place.

Read the lesson: Debugging Logic and State →

Practise Debugging Logic and State

The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Debugging Logic and State