Skip to content

Demo 1: Finding and Fixing Basic Bugs 🐛

Goal

Use print statements and error messages to find and fix simple bugs.

Setup

  • Provided script demo1-print-debugging.py with common beginner bugs:
  • Wrong variable names
  • Incorrect calculations
  • Typos in function names and parameters
  • Off-by-one errors in loops
  • Parameter order issues

Tasks

  1. Run the script. Observe the error message.
  2. Read the traceback. Identify the line and error type.
  3. Add print statements before the error to inspect variables.
  4. Fix the bug. Rerun to confirm.
  5. Repeat for other bugs in the script.

Expected Outcomes

  • Students can interpret error messages.
  • Students can use print statements to trace program flow.
  • Students fix syntax and logic errors confidently.

Notes