Making a variable

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

Making a variable

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which variable name is clearest for storing a player's points in a game?
A x1
B score
2. What does the Make a Variable button do?
A Creates a named box that can store a value
B Moves a sprite across the stage
3. You want to keep track of how many lives a player has left. Which name is best?
A lives
B thing
4. A variable called timer is ticked in the variable list. What happens?
A The variable is deleted
B Its value is shown on the stage
5. You untick the box next to the score variable. What happens to score?
A It is hidden from the stage but still exists
B It is erased and cannot be used

Match the Pairs

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

Left columnRight column
1Make a Variable AThis is not the real problem. The score would show on the stage if the box is ticked. A player who can't see it means the box is unticked, so tick it to show the variable.
2[x] score (tick box) BMake a Variable: lives left
3A clear name tells you what the variable stores CThe name x is not clear. It does not tell you what the variable stores. A better name is score or lives left.
4Hide a variable from the stage by unticking its box DShows the score variable on the stage so the player can see it
5Make a Variable: x ECreates a new named box that can store a value, such as a score
6Player cannot see the score, but the score box is ticked and the variable is made F[ ] score (box unticked)

Definitions

Make a Variable

Fill in the Blanks

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

1.
Click _______________, then type a name
2.
// counts the points a player earns Make a Variable named _____
3.
____ variable [score]
4.
hide ________ [score]
5.
Untick the box to ____ score on the stage

Spot the Error

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

Question 1
A Make a Variable: score
B set scor to 0
C show variable score
Question 2
A Goal: show the score on stage
B Make a Variable: score
C when green flag clicked
D hide variable score
Question 3
A Make a Variable: lives
B when green flag clicked
C set 3 to lives
Question 4
A Make a Variable: time left
B when green flag clicked
C set time to 30
D show variable time left
Question 5
A Make a Variable: x
B set score to 0
C show variable score

Answer Key

Making a variable
Section A: Quick Questions
Q1
B — score
Q2
A — Creates a named box that can store a value
Q3
A — lives
Q4
B — Its value is shown on the stage
Q5
A — It is hidden from the stage but still exists
Section B: Match the Pairs
Q1
Make a Variable → Creates a new named box that can store a value, such as a score
Q2
[x] score (tick box) → Shows the score variable on the stage so the player can see it
Q3
A clear name tells you what the variable stores → Make a Variable: lives left
Q4
Hide a variable from the stage by unticking its box → [ ] score (box unticked)
Q5
Make a Variable: x → The name x is not clear. It does not tell you what the variable stores. A better name is score or lives left.
Q6
Player cannot see the score, but the score box is ticked and the variable is made → This is not the real problem. The score would show on the stage if the box is ticked. A player who can't see it means the box is unticked, so tick it to show the variable.
Section C: Definitions
Q1
Make a Variable — A block button that creates a named box to store a value, like a score. You choose a clear name, and a tick box shows or hides the variable on the stage.
Section D: Fill in the Blanks
Q1
Click Make a Variable, then type a name
Q2
// counts the points a player earns Make a Variable named score
Q3
show variable [score]
Q4
hide variable [score]
Q5
Untick the box to hide score on the stage
Section E: Spot the Error
Q1
B — The variable was made with the name score, but this line uses scor. A variable name must match exactly. It should be: set score to 0
Q2
D — The goal is to show the score on the stage, but this block hides it. It should be: show variable score
Q3
C — The set block needs the variable name first and then the value. It should be: set lives to 3
Q4
C — The variable is called time left, not time. The name must match exactly, so it should be: set time left to 30
Q5
A — The name x does not tell us what is stored, and it does not match the later lines. Choose a clear name: Make a Variable: score