Teaching Materials
What is new in this level?
In this level we are expanding on the {if} and {repeat} again. In the previous level the students have learned how to use multiple lines after {repeat, {if}, {elif} or {else}. Now the students will also learn about nesting, putting an {if} or {repeat} inside an {if} or {repeat}. They will also learn two new commands: {and} and {or}. This will bring the students a lot more possibilities to make more versitile programs.
New in this level:
- Nesting {if} and {repeat}
- Using {and} and {or} after an {if}
- Slides Present the level, one concept at a time
Common mistakes
Students make mistakes with indentation
The hardest part about this level is getting the indentation right. Students love nesting if statements, sometimes even inside other nested if statements. Keeping track of indentation can get pretty tough.
print 'Robin is walking downtown'
location = ask 'Is Robin going into a shop, or does she go home?'
if location is shop
print 'She enters the shop.'
print 'Robin sees an interesting looking book'
book = ask 'Does Robin buy the book?'
if book is yes
print 'Robin buys the book and goes home'
else
print 'Robin leaves the shop and goes home'
else
print 'Robin goes home'
This is the correct code. Try to keep track of all the different constructions when putting if statements inside other if statements.
print 'Robin is walking downtown'
location = ask 'Is Robin going into a shop, or does she go home?'
if location is shop
print 'She enters the shop.'
print 'Robin sees an interesting looking book'
book = ask 'Does Robin buy the book?'
if book is yes
print 'Robin buys the book and goes home'
else
print 'Robin leaves the shop and goes home'
else
print 'Robin goes home'
Students confuse and with or
Both commands might appear similar, but their functions are very different.
game = ask 'Do you want to play a game?'
time = ask 'Do you have time to play?'
if game is 'yes' or time is 'yes'
print 'Lets play!'
In this case, the person should answer yes on both questions, so you should use and.
game = ask 'Do you want to play a game?'
time = ask 'Do you have time to play?'
if game is 'yes' and time is 'yes'
print 'Lets play!'
Students make incomplete lines with or
After an or the conditional should be complete.
color = ask 'What color do you like?'
if color is blue or green
print 'Beautiful!'
Complete the line like this:
color = ask 'What color do you like?'
if color is blue or color is green
print 'Beautiful!'