Page 107 - 2422_C5_Flipbook
P. 107
Types of Variables
Variables can store numbers as well as letters. A variable that stores numbers is called a numeric
variable. These numbers are used in calculations. Examples are 48, -986, 12345, etc.
A variable that stores letters in the form of strings or characters is called string variable. A string
variable can store names, words, sentences, numbers, and enclosed in quotation marks. For
example, “Kavita”, “I am 12 years old” and “12345”. These variables are not used in calculations.
Suppose, you have to code a dance party in Scratch where characters keep
dancing in a loop until stopped? Which block will you use for this and which
songs would you play in the program?
Creating Variables in Scratch
To create variables in Scratch, follow the given steps:
Step 1: Click on Variables block category. A set of blocks appears in the block palette.
Step 2: Click on Make a Variable block. A New Variable dialog box appears. Type a variable
name in the New variable name box.
Step 3: Click on the radio button of either of the options. Click on For all sprites if you want
this variable to appear for all the sprites.
Or
Click on For this sprite only if you want this variable to appear for the selected sprite
only. Here we have added the variable fruit. It will be available for all the sprites.
Step 4: Click OK button.
2
1 3
4
Conditional Blocks in Scratch 105

