IfIsLoop

Misconception:

The body of the if-statement executes as many times as needed to ensure the condition does not hold anymore and execution can continue.

Incorrect

The body of an if-statement executes repeatedly, as long as the condition holds

Correct

The body of an if-statement executes at most once

Correction
Here is what's right.

The body of an if-statement either executes, or it does not execute.

Students might mistake if-statements for while-statements.

Conditional: Execute body zero or one times

if a > 0:
    a = a - 1
true
false
a > 0
a = a - 1
x

Loop: Execute body zero or more times

while a > 0:
    a = a - 1
true
false
a > 0
a = a - 1
x

Symptoms
How do you know your students might have this misconception?

  • Students claim an if-statement means “ensure that this condition holds”
  • Students claim an if-statement “corrects things whenever this condition does not hold”

Value
How can you build on this misconception?

Read through Python’s tutorial on Control Flow to learn more.

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.