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.pywith common beginner bugs: - Wrong variable names
- Incorrect calculations
- Typos in function names and parameters
- Off-by-one errors in loops
- Parameter order issues
Tasks¶
- Run the script. Observe the error message.
- Read the traceback. Identify the line and error type.
- Add print statements before the error to inspect variables.
- Fix the bug. Rerun to confirm.
- 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.