This programming language misconception is about
if
-statements.
Let's first define a few functions:
Now let's run two different versions of code.
You see that the two versions are not equivalent.
The second one checks the condition twice,
and if some state changes in-between checks
(e.g., here the value of g
changes),
the condition may evaluate to a different value.
This misconception illustrates one of the consequences of mutability:
knowing that c()
is True
at some point
does not allow us to assume that not c()
will be False
in the future.
If you would like to learn more about this misconception, including its possible origins, symptoms students who hold this misconception might exhibit, the related programming language concepts, links to the corresponding parts of the Python language specification, and related misconceptions, check out ConditionalIsSequence in the progmiscon.org misconception inventory.
This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.
ConditionalIsSequence
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version 1e22f67 (Sat, 19 Jul 2025 12:40:41 GMT)