1 Answers
🚀 Quick Study Guide: Scratch Variables for Beginners
- 💡 What is a Variable? A variable in Scratch is like a named storage container for a piece of information (a number, word, or phrase) that can change while your program runs.
- ➕ Creating Variables: Go to the 'Variables' category, click 'Make a Variable'. You choose if it's 'For all sprites' (global) or 'For this sprite only' (local).
- 🌍 Global Variables ('For all sprites'): These variables can be seen and modified by ANY sprite in your project, as well as the Stage. Ideal for scores, timers, or game states.
- 👤 Local Variables ('For this sprite only'): These variables belong exclusively to the sprite they are created in. Each instance of a cloned sprite will have its own independent copy of a local variable. Perfect for a sprite's health, speed, or individual counter.
- ⚙️ Key Variable Blocks:
- 🔄
set [variable] to [value]: Assigns a specific value to a variable. - ⬆️
change [variable] by [value]: Adds or subtracts a value from the current variable's value. (e.g.,change score by 1). - 👁️
show variable [variable]: Makes the variable's monitor visible on the Stage. - 🚫
hide variable [variable]: Hides the variable's monitor from the Stage.
- 🔄
- 🎯 Common Uses: Keeping track of scores, game timers, character health, levels, user input, or counting loops.
🧠 Practice Quiz
Test your knowledge of Scratch variables!
What is the primary purpose of a variable in Scratch?
A. To create a new sprite on the stage.
B. To store a value that can change during the project's execution.
C. To draw lines and shapes on the canvas.
D. To play sound effects and music.Which variable scope would you typically use for a game's main score that all sprites might affect or display?
A. For this sprite only
B. For specific sprites
C. For all sprites
D. For the backdrop onlyIf a variable named 'score' is currently 5, and you use the block
change [score] by [2], what will the new value of 'score' be?A. 5
B. 2
C. 7
D. 3Which of the following blocks is used to give a variable an initial value, like setting a timer to 60 seconds at the start of a game?
A.
change [variable] by [value]
B.set [variable] to [value]
C.show variable [variable]
D.hide variable [variable]You have a sprite character that needs to track its own individual 'health' in a game where multiple clones of this character might exist. What kind of variable should you use for 'health'?
A. A global variable ('For all sprites')
B. A local variable ('For this sprite only')
C. A list variable
D. A broadcast messageWhat happens when you use the
hide variable [my variable]block?A. The variable is deleted from the project.
B. The variable's value is set to 0.
C. The variable's monitor disappears from the Stage.
D. The variable stops changing its value.Which type of data can a Scratch variable hold?
A. Only numbers
B. Only text (words/phrases)
C. Only true/false values
D. Numbers, text, and boolean (true/false) values
Click to see Answers
1. B
2. C
3. C
4. B
5. B
6. C
7. D
Join the discussion
Please log in to post your answer.
Log InEarn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! 🚀