Skip to main content
Back to module
Teaching Computer Science · CS Pedagogy

Common novice misconceptions

Reading20mLesson 1 of 3 in this module

What you'll learn

  • Diagnose a misconception from code
  • Describe the notional machine a novice should hold
  • Recognise common misconceptions such as assignment as equation and print vs return
  • Use trace tables and targeted questions before correcting code

Recognise the most common novice programming misconceptions and diagnose them from a student's code.

Why it matters

When a student's program is wrong, it is tempting to fix the line and move on. But most novice errors are not typos: they come from a consistent, wrong mental model of how the computer works. Fix the line and the model stays; the same error comes back next week in a different form. Good CS teachers learn to read a wrong answer as evidence of what the student believes, then target that belief.

The core idea: notional machines

Researchers use the term notional machine for the simplified model of the computer that a teacher wants students to hold: "a variable is a named box holding one value", "the program runs one line at a time, top to bottom, unless a loop or call sends it elsewhere". Misconceptions are gaps or errors in that model. Making the notional machine explicit (with diagrams, tracing tables and visualisers) is one of the most effective things you can do.

Common misconceptions and how they show up

MisconceptionWhat the student believesTypical evidence
Assignment as equationa = b links a and b foreverexpects a to change when b changes later
Variables hold historya variable remembers all its past valuestraces show several values in one box
Order does not matterthe computer reads the whole program and "understands" ituses a variable before assigning it
The computer knows what I meannames carry meaning (largest will find the largest)names a variable and expects behaviour
Print equals returnshowing a value is the same as giving it backfunction prints but caller gets None
if loopsan if repeats like whileexpects an if body to run many times
Loop runs once more / lessunclear about where range stopsoff-by-one errors on boundaries
= vs ==the symbols are interchangeableassignment inside a condition (in languages that allow it)

Worked example: diagnosing from code

A student writes this to swap two values:

Python
a = 5
b = 9
a = b
b = a
print(a, b)   # student expects: 9 5

The output is 9 9. Possible beliefs behind it:

  1. Assignment as equation or simultaneous: the student thinks both lines happen "at once", like swapping in maths.
  2. Variables hold history: they think a still "remembers" 5 after a = b.

A good diagnostic question separates them: "After line 3, what is in a? Is 5 stored anywhere?" A student who says "5 is still in a as well" has the history misconception. Then you address the model, not just the code: trace line by line in a table, one row per line, one column per variable.

lineab
15-
259
399
499

Only after the model is fixed do you introduce a temporary variable (temp = a).

Worked example: print vs return

Python
def double(n):
    print(n * 2)

result = double(4) + 1

The program shows 8 and then crashes with TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'. The student is confused: "But it printed 8!" The misconception is that printing gives a value back. Ask: "Where does 8 go when it is printed? Where does the value go when it is returned?" A picture of the screen versus the caller helps.

Teaching moves that help

  • Predict before run. Ask students to predict output before running code. Wrong predictions surface misconceptions quickly.
  • Trace tables and visualisers. Python Tutor (pythontutor.com) shows variables and frames step by step.
  • Diagnostic multiple-choice questions where each wrong answer matches a known misconception, so the choice tells you the belief.
  • Refutation. Show a case where the wrong model predicts something different from what happens, then explain why.

Common mistakes (for teachers)

  • Fixing the code for the student. You remove the evidence and keep the misconception.
  • Assuming it is carelessness. Consistent errors usually mean a consistent model.
  • Explaining with too much abstraction. "Memory addresses" can confuse beginners; start with boxes and arrows.
  • Ignoring language effects. = reads as "equals" in maths. Say "gets" or "is assigned" aloud.

Quick recap

  • Most novice errors come from wrong mental models, not typos.
  • Make the notional machine explicit with tracing tables and visualisers.
  • Learn the common misconceptions: assignment as equation, print vs return, if as loop, off-by-one.
  • Diagnose with targeted questions and predictions before you correct.

Key terms (5)

notional machine
The simplified model of how the computer runs a program that a teacher wants students to hold.
Assignment as equation
The misconception that a = b links the two variables forever, so a changes when b changes later.
Print equals return
The misconception that showing a value on screen is the same as giving it back to the caller.
trace
To follow a program line by line, recording each variable's value in a table, one row per line.
Refutation
Showing a case where the wrong mental model predicts something different from what actually happens, then explaining why.

Recap

  • Most novice errors come from consistent wrong mental models, not typos.
  • Make the notional machine explicit with trace tables and visualisers such as Python Tutor.
  • Know the common misconceptions: assignment as equation, variables holding history, print vs return, if as a loop, off-by-one.
  • Diagnose with predictions and targeted questions before correcting.
  • Fixing the code for the student removes the evidence and keeps the misconception.
Also in this lesson: