Revise Computingrevisecomputing.co.uk
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates

Knowledge organisers / Testing

Debugging

All topicsPractise exam questions
Knowledge organiser

Testing

301.13f

Find and fix logic errors.

What you need to know

Debugging is the process of finding and fixing errors. Syntax errors are caught by Python, but logic errors produce wrong results and must be found by testing and tracing.

Key points

  • Syntax error: code won't run (e.g. missing colon)
  • Logic error: code runs but gives wrong answer
  • Use print() statements to check variable values
  • Use a trace table to find where logic goes wrong
  • Fix the bug, then re-test to confirm

Code examples

Debugging with print
python
def average(a, b):
    total = a + b
    print("DEBUG: total=" + str(total))  # temporary
    avg = total / 2
    return avg

print(average(10, 20))  # DEBUG: total=30 → 15.0