› Teaching Materials › Prepare level 16

What is new in this level?

In this last level of Hedy the students will learn how to use a while loop and practise more with the new syntax. After this level, students are ready to continue programming in 'real' Python compilers.

New in this level:

  • The while loop
  • Slides Present the level, one concept at a time

Common mistakes

Students forget indentation in the while loop

What students get wrong

Indentation is often hard for students.

answer = 0
while answer != 25
answer = ask 'What is 5 times 5?'
print 'A correct answer has been given'
How to fix it

This is the correct code:

answer = 0
while answer != 25
    answer = ask 'What is 5 times 5?'
print 'A correct answer has been given'

Students (accidentally) create an infinite loop

What students get wrong

Students create a while loop, but no way to stop the loop.

alarm = on
while alarm = on
    play C
    play D
How to fix it

This is the correct code:

# Press the red 'stop program' button to force the program to stop