The forever block

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

The forever block

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does the forever block do with the blocks inside it?
A It repeats them again and again until the program is stopped
B It runs them one time and then finishes
2. Which block is the best choice if a game needs to keep checking whether the player touches a wall?
A A single if block on its own
B forever with an if block inside
3. Which block can end a program that is stuck in a forever loop?
A stop all
B say Hello!
4. True or false: A forever block counts how many times it repeats and stops at 10.
A False. It keeps going until the program is stopped
B True. It stops after 10 repeats
5. Which script keeps moving a sprite across the stage until you press stop?
A move 10 steps
B forever: move 10 steps

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1forever AThe forever block is inside the if block, so the check only happens once. If the sprite is not touching the edge at that moment, nothing repeats. The if block should go inside forever.
2stop all BThe stop all block is placed after forever, so it never runs because forever never finishes. Put stop all inside an if block inside the forever loop.
3Keep checking whether the player has touched the edge, over and over, while the program runs CA block that repeats the blocks inside it again and again until the program is stopped
4End a forever loop when the game is over by stopping the whole program DA block that stops the whole program, even a forever loop that would otherwise keep going
5if touching edge then forever say Ouch! Eforever if score = 10 then stop all
6forever move 10 steps stop all Fforever if touching edge then say Ouch!

Definitions

forever

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
when green flag clicked _______ move 10 steps
2.
forever __ touching edge then turn 15 degrees
3.
forever if lives = 0 then ________
4.
forever if touching Cat ____ say Ouch!
5.
forever if score _ 9 then stop all

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A when green flag clicked
B forever
C if touching edge?
D stop all
E end
F end
Question 2
A when green flag clicked
B forever
C when touching Ball? then
D say Goal! for 1 seconds
E end
F end
Question 3
A when green flag clicked
B forever 10
C turn 5 degrees
D end
Question 4
A when green flag clicked
B forever
C if score + 10 then
D stop all
E end
F end
Question 5
A when green flag clicked
B forever
C if touching edge? then
D wait 1 seconds
E end
F end

Answer Key

The forever block
Section A: Quick Questions
Q1
A — It repeats them again and again until the program is stopped
Q2
B — forever with an if block inside
Q3
A — stop all
Q4
A — False. It keeps going until the program is stopped
Q5
B — forever: move 10 steps
Section B: Match the Pairs
Q1
forever → A block that repeats the blocks inside it again and again until the program is stopped
Q2
stop all → A block that stops the whole program, even a forever loop that would otherwise keep going
Q3
Keep checking whether the player has touched the edge, over and over, while the program runs → forever if touching edge then say Ouch!
Q4
End a forever loop when the game is over by stopping the whole program → forever if score = 10 then stop all
Q5
if touching edge then forever say Ouch! → The forever block is inside the if block, so the check only happens once. If the sprite is not touching the edge at that moment, nothing repeats. The if block should go inside forever.
Q6
forever move 10 steps stop all → The stop all block is placed after forever, so it never runs because forever never finishes. Put stop all inside an if block inside the forever loop.
Section C: Definitions
Q1
forever — A block that repeats the blocks inside it again and again until the program is stopped, for example with stop all. You can put an if block inside it to keep checking something.
Section D: Fill in the Blanks
Q1
when green flag clicked forever move 10 steps
Q2
forever if touching edge then turn 15 degrees
Q3
forever if lives = 0 then stop all
Q4
forever if touching Cat then say Ouch!
Q5
forever if score > 9 then stop all
Section E: Spot the Error
Q1
C — An if block needs the word 'then' so the program knows what to do when the check is true. It should be: if touching edge? then
Q2
C — Inside a forever block we check things with an if block, not a 'when' block. The line should be: if touching Ball? then
Q3
B — The forever block does not have a number. It repeats until the program is stopped. The line should just be: forever
Q4
C — The + block adds numbers. It does not check anything. To see if the score is 10, use the = block: if score = 10 then
Q5
D — Waiting does not end the program, so the forever block would keep going. To end the program, use: stop all