Programming Essentials in Scratch: Unit Exam A
Instructions
- Time allowed
- 25 minutes
- Total marks
- 25
- Calculator
- No calculator is permitted.
- Answer all the questions.
Questions
Tick one box.
- LB A set of step by step instructions to solve a problem
An algorithm is a precise sequence of steps that solves a problem.
| Sequence | Selection | Iteration | |
|---|---|---|---|
| if touching edge then | |||
| repeat 10 | |||
| Blocks joined one after another and run in order | |||
| if score = 5 then ... else |
Tick one box in each row.
- Lif touching edge then: Selection
- Lrepeat 10: Iteration
- LBlocks joined one after another and run in order: Sequence
- Lif score = 5 then ... else: Selection
if blocks are selection, repeat and forever are iteration, and blocks in order are sequence.
when green flag clicked
set [score] to 0
repeat 5
change [score] by 2
end
say (score)- L10
The loop runs five times, adding 2 each time: 0 + 2 + 2 + 2 + 2 + 2 = 10.
repeat 4
change x by 25
end- L100
Four moves of 25 is 100.
Tick one box.
- LD when green flag clicked
when green flag clicked is the event that starts scripts when the green flag is pressed.
Tick one box.
- LC A named store for a value that can change while the program runs
A variable is a named store, such as score, whose value can change.
Tick one box.
- LA forever
forever keeps checking for as long as the game runs. repeat 10 would only check ten times.
pen down
repeat 3
move 100 steps
turn 120 degrees
end- Ltriangle
Three equal sides with a 120 degree turn at each corner make an equilateral triangle.
- L90
A square has four corners and the turns must add up to 360, so 360 / 4 = 90 degrees.
- LIt sends a message to other sprites or the stage
- LScripts that start with when I receive that message then run, so one sprite can make others act
A broadcast sends a message to every sprite and the stage. Any script that begins with when I receive that message starts running, so one sprite can make other sprites act, for example starting the next level.
Tick one box.
- LA Finding and fixing a mistake that makes a sprite move the wrong way
Debugging means finding and fixing errors in a program.
if <(score) > 10> then
say [Great]
else
say [Keep going]
end| score | The sprite says |
|---|---|
| 5 | |
| 10 | |
| 11 |
- LKeep going
- LKeep going
- LGreat
Only a score greater than 10 says Great. 10 is not greater than 10, so it says Keep going.
- LThe score is set back to 0 inside the loop, every time round
- LThe change score block is not run: the condition is never true, it is in the wrong place, or it changes by 0 or the wrong variable
The score might be set to 0 inside the forever loop, so it is reset every time round. Or the change score by 1 block never runs, because the if condition is never true, the block is not joined to the script, or it changes a different variable.
Tick two boxes.
- LC when this sprite clicked
- LD when space key pressed
- LNo marks if more than 2 boxes are ticked
Event blocks start scripts when something happens, such as a click or a key press.
Tick one box.
- LB Repeating a set of instructions
Iteration is repetition: a loop.
repeat 3
repeat 4
play sound [pop]
end
end- L12
The inner loop plays the sound 4 times, and it runs 3 times: 3 x 4 = 12.
Tick one box.
- LA Pauses the script for one second
It pauses that script for one second before the next block runs.