Teaching Materials
What is new in this level?
The if and else are introduced in this level.
New in this level:
- Make a choice with
ifandelse
- 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
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!
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
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!'
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
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!
Always use 2 quotes in a print command.
if name is Hedy print 'fun' else print 'meh!'
Students use quotes around variable names
In this level there are no quotes around variable names.
if name is 'Hedy' print 'fun' else print 'meh!'
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
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?'
Add an underscore.
chosen_door is ask 'Which door do you pick?'
Students want multiple answers to be correct
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'
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
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!'
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!'