Key Stage 3 · Y7.2
Programming Essentials in Scratch
Name
Class
Date
Mark / 26
Section A
Circle the letter of the correct answer. One mark each.
- 1Which construct means repeating instructions?1
- ASequence
- BVariable
- CIteration
- DSelection
- 2What does
repeat until <touching edge?>do?1- ARuns once when the edge is touched
- BRepeats the blocks inside until the sprite touches the edge
- CRepeats exactly ten times
- DRepeats forever
- 3Why should a score variable be set to 0 when the green flag is clicked?1
- AOtherwise the score from the previous game carries over
- BTo create the variable
- COtherwise the program will not run
- DTo make the game faster
- 4Which blocks would draw a triangle?1
- Arepeat 3 [move 100 steps, turn 90 degrees]
- Brepeat 4 [move 100 steps, turn 90 degrees]
- Crepeat 3 [move 100 steps, turn 120 degrees]
- Dforever [move 100 steps, turn 120 degrees]
- 5What is an event in Scratch?1
- AA loop that repeats forever
- BA variable that stores a number
- CSomething that happens which starts a script, such as a key press
- DAn error in the program
- 6Which condition would check that a player has more than 5 lives?1
- Alives = 5
- Blives > 5
- Clives < 5
- Dlives > 5 or lives < 5
- 7What does broadcasting allow you to do?1
- ASave the project online
- BChange the background colour
- CMake the sprite move faster
- DSend a message so other sprites can respond
- 8A sprite should bounce when it hits the edge. Which construct is needed?1
- ASelection, to check whether it is touching the edge
- BOnly sequence
- COnly a variable
- DOnly an event
- 9What is debugging?1
- AFinding and fixing errors in a program
- BSaving a project
- CMaking a program run faster
- DAdding more sprites
- 10Which loop should be used when you do not know how many repetitions are needed?1
- Arepeat 10
- BNo loop is needed
- CA single if block
- Drepeat until
Section B
Answer in the space provided. The number of marks tells you how many separate points to make.
- 1StateState what is meant by sequence, selection and iteration.3
- 2ExplainExplain why a variable is useful in a game, giving an example.3
- 3ExplainA student's Scratch game keeps the score from the previous game when it is restarted. Explain the cause of this problem and how to fix it.3
- 4DescribeDescribe how you would use a repeat block to draw a square, and explain why using a loop is better than repeating the blocks four times.4
- 5WriteA game should say 'Well done' when the score reaches 10, and 'Keep trying' otherwise. Write the blocks you would use.3
Mark scheme
Section A
Section B
1 State what is meant by sequence, selection and iteration. 3
One mark for each of the following, to a maximum of 3.
- Sequence is instructions carried out in order one after another
- Selection is choosing what to do based on a condition
- Iteration is repeating instructions
Model answer. Sequence means carrying out instructions one after another in the order they are written. Selection means the program chooses between different paths depending on whether a condition is true or false, using an if block. Iteration means repeating a set of instructions, either a fixed number of times or until a condition is met.
2 Explain why a variable is useful in a game, giving an example. 3
One mark for each of the following, to a maximum of 3.
- A variable stores a value that can change while the program runs
- Gives a valid example such as score, lives or a timer
- Explains how it is used, such as increasing the score when a target is hit
Model answer. A variable is a named store that holds a value which can change while the program is running, which is exactly what a game needs to keep track of what is happening. For example, a score variable would be set to 0 when the green flag is clicked, and then changed by 1 every time the player catches a falling object. The current value can then be checked in a condition, so the game can end or move to the next level when the score reaches a target.
3 A student's Scratch game keeps the score from the previous game when it is restarted. Explain the cause of this problem and how to fix it. 3
One mark for each of the following, to a maximum of 3.
- Variables keep their value between runs
- The score is never set back to zero when the game starts
- Fix by adding a set score to 0 block after the green flag is clicked
Model answer. The cause is that a variable keeps whatever value it was last given, and that value is remembered even after the program stops. Because the student's script never sets the score back to zero, the new game simply continues from the value left over at the end of the previous one. The fix is to add a set score to 0 block immediately after the when green flag clicked block, so that the score is reset every time a new game begins.
4 Describe how you would use a repeat block to draw a square, and explain why using a loop is better than repeating the blocks four times. 4
One mark for each of the following, to a maximum of 4.
- Uses a repeat 4 block
- Contains a move block and a turn 90 degrees block
- A loop means less code to write and read
- It is easier to change, for example altering the size or number of sides in one place
Model answer. To draw a square you would use a repeat 4 block containing a move 100 steps block followed by a turn 90 degrees block. Each pass draws one side and turns the corner, and after four passes the sprite has turned through 360 degrees and returned to where it started. Using a loop is better than writing the two blocks out four times because the script is much shorter and easier to read, and more importantly it is far easier to change. If you wanted a larger square you would only have to edit one move block instead of four, and if you wanted a different shape you would only have to change the repeat number and the turn angle.
5 A game should say 'Well done' when the score reaches 10, and 'Keep trying' otherwise. Write the blocks you would use. 3
One mark for each of the following, to a maximum of 3.
- Uses an if else block
- Condition tests whether the score is 10 or more
- Correct message in each branch
Model answer. if <score > 9> then say "Well done" else say "Keep trying" The if else block gives two paths and only one of them runs. The condition checks whether the score has reached 10, and because Scratch has a greater than block rather than a greater than or equal to block, testing for greater than 9 is the usual way to include 10 itself.