If we are teaching programming at Year 9 or 10 it is important in my view that we identify general and language specific misconceptions as early as possible, potentially even at primary school.
With regard to Python I see student misconceptions arising in the following:
- Confusing assignment statements and comparison statements in Python.
- Variables as a concept
- Variables verses constants.
- Boolean data types also present a conceptual challenge, especially when statements such as while True:are used.
- Numeric and string variables that contain a number ie 6 verses “6”
- Scope of local and global variables
- Assignment of variable via return from a function…
- Comparison operators >= <= !=
- Logical operators: and or not
- Indenting to determine blocks of statements
- Adding strings and adding numbers either literal or variables.
Computer Science Education Research on Programming: What We Know and How We Know It by Lori E Postner provides some useful perspectives. Selected quotes:
Du Boulay (1986) identified misconceptions about variables based upon the analogies used in class. For example, the box or drawer with a label on it may lead students to believe that a variable can hold more than one value at a time.
A common mistake, when using a variable to keep a running total, is to forget to initialize the total to zero. This omission is reasonable when following the box analogy. After all, if one has not put anything into a box, it’s empty, which is sort of like zero.
The notion that a computer program ‘knows’ what input values should go into variable names like LARGEST dies hard, even though students know in principle that the choice of variable names in theirs, a point incoherent with such wisdom on the part of the computer.
…understanding variables involves knowing that the label can store a value that changes. She concluded that programming helps students understand mathematical variables.