› Teaching Materials › Prepare level 5

What is new in this level?

The if and else are introduced in this level.

New in this level:

  • Make a choice with if and else
  • Slides Present the level, one concept at a time
  • Workbook Exercises to print, away from the screen Work in progress

Common mistakes

Students forget to use print in an if command

What students get wrong

After students use if or else they forget to use a second command like print or ask.

if name is Hedy 'Great!'
else  Hedy is better!
How to fix it

Add the print command to fix it.

if name is Hedy print 'Great!'
else print 'Hedy is better!'

Students might use two different names for the same variable

What students get wrong

In this example the student has used 'horse' and 'name' for the same variables.

horse is ask 'What is your horse called?'
if name is Bonfire print 'cool'
else print 'less cool!'
How to fix it

Always check whether the variable has the same name throughout the code. Slight differences can be hard to spot (for example plurals) but they will interfere with the code.

horse is ask 'What is your horse called'
if horse is Bonfire print 'cool!'
else print 'less cool!'

Students still forget the quotes on both sides

What students get wrong

Using the if command can make the code lines very long and students tend to forget to use quotes.

if name is Hedy print fun
else print 'meh!
How to fix it

Always use 2 quotes in a print command.

if name is Hedy print 'fun'
else print 'meh!'

Students use quotes around variable names

What students get wrong

In this level there are no quotes around variable names.

if  name  is 'Hedy' print 'fun'
else print 'meh!'
How to fix it

Remove the quotes to get the code to work.

if name is Hedy print 'fun'
else print 'meh!

Students use long variable names containing two or more words

What students get wrong

Variables in Hedy can't contain spaces, so, in order to use together several words, students need to connect them using underscores (_)

chosen door is ask  'Which door do you pick?'
How to fix it

Add an underscore.

chosen_door is ask 'Which door do you pick?'

Students want multiple answers to be correct

What students get wrong

For example this student wants Hedy to tell all his friends that they are funny, while other classmates should be told that they are not.

if name is Jesse, David, Souf print 'You are funny' else print 'You are not funny'
How to fix it

You could use the in command for that. While it is explained in a higher level, it does already work in level 5. Another solution is to use multiple if commands and no else command. The disadvantage is that it won't tell the other classmates that they are not funny.

friends is Jesse, David, Souf
name is ask 'Who are you?'
if name in friends print 'You are funny'
else print 'You are not funny'

# or

name is ask 'Who are you?'
if name is Jesse print 'You are funny'
if name is David print 'You are funny'
if name is Souf print 'You are funny'

The students make the variable name the same as the value in the if statement

What students get wrong

In the example below the password is 'password'. This will result in it always being correct.

password is ask 'What is the password?'
if password is password print 'Access granted'
else print 'Access denied!'
How to fix it

Pick a different name for your variable.

secret_password is ask 'What is the password'
if secret_password is password print 'Access granted!'
else print 'Access denied!'