Phase 5: Debugging Methodology · ~30 minutes · Python · print debugging · logging
The Cheapest Tool First
A single well-placed print statement finds most bugs faster than launching a debugger. Reach for the expensive tool because you measured a need for it, not out of habit.
Hiring signal: Escalates debugging tools deliberately, starting cheap, instead of reaching for the heaviest tool out of habit
What you will learn
- Explain the real escalation ladder: print/logging first, interactive debuggers next, specialized tracing last
- Diagnose a bug using only print/logging before reaching for anything heavier
- Recognize when a bug's subtlety genuinely warrants a more sophisticated tool
- Choose the cheapest appropriate tool for a given bug description
Introduction
Type: Learn Languages: Python Prerequisites: Phase 04 (Databases & SQL for AI/ML) Time: ~30 minutes
Objective
Learning objectives
- Explain the real escalation ladder: print/logging first, interactive debuggers next, specialized tracing last
- Diagnose a bug using only print/logging before reaching for anything heavier
- Recognize when a bug's subtlety genuinely warrants a more sophisticated tool
- Choose the cheapest appropriate tool for a given bug description
What you're building
Given (or writing your own versions of) three bugs of genuinely increasing subtlety, following this lesson's three-bug pattern:
- Diagnose the first (obvious) bug using exactly one print statement, and fix it
- Diagnose the second (input-dependent) bug using multiple prints across a deliberately chosen range of inputs including a boundary value, and fix it
- Diagnose the third (subtle, state-related) bug by tracing it across multiple calls — using prints,
id(), or a debugger if you judge it genuinely warranted — and fix it - Write
escalation_log.txt stating which tool you used for each of the three, and one sentence justifying why that was the appropriately cheap choice for that bug's actual subtlety
A function produces a wrong result, and you can already tell exactly which line is wrong just by reading the function — it's short, and the bug is a single misplaced operator. What's the appropriate first tool?
This describes exactly this lesson's Bug 1 pattern: a short function, a bug already visible on inspection. The cheapest tool — a print statement confirming the actual vs. expected value, or simply reading the one-line function carefully — resolves this immediately. Reaching for a debugger or profiler here adds real setup time to a diagnosis that's already complete, which is precisely the discipline this lesson is building: match the tool to the bug's actual subtlety, escalating only when the cheaper tool has genuinely stopped being enough.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers The Problem, Check Yourself, Key Terms & Next — plus a hands-on lab, quiz, and project artifact.
Create a free account to unlock Phase 0 and Phase 1 of every course — no credit card.
Browse all courses · View pricing · DeVenture Academy