Functions · Debugging

Judge — analyse and evaluate L4 Analysis Relations ~4 min

The average that came back empty

The programmer expected this program to print only 'Average is 6.0'. Instead it prints 6.0 on one line and 'Average is None' on the next. Identify the bug.

def average(a, b):
    print((a + b) / 2)

result = average(4, 8)
print("Average is", result)

Choose one

Why this activity was chosen
  • Bloom level: L4 Analysis: Find the fault and say why it matters.
  • Block Model level: Relations (step 3 of 4): how parts of the program affect each other: variable updates, function calls, data flow and control flow.
  • Misconception targeted: shown after you answer, so it does not give the answer away.

Debugging is analysis: locating the mismatch between intended and actual behaviour. In an AI-rich setting this is the same skill used to inspect generated code.

AI’s role here: AI may hint at the region of the program to inspect. It must not point at the exact line as a completed answer.