Page 86 - CG_v2.1_flipBooks_class_5
P. 86
All the numbers, text, date or pictures that we use in a program are called data. We store
this data in the computer memory so that we can get information from it later. This data
is stored in variables. It is called variable because it does not have a fixed value, its value
changes. For example, in the move block, the variable has a value 10 by default. You can
modify this value according to your script.
Types of Variables
There are two types of variables. They are as follows:
Global Variables
If a variable is created to be used and modified by all the sprites, then it is known as a global
variable. A Global variable can be created on any sprite but its value can be accessed or
modified by other sprites used in the project.
Local Variables
If a variable is created to be used and modified by a single sprite only, then it is known as a local
variable. Local variables can only be accessed or modified from the sprite where it was created.
Creating Variables in Scratch
To create variables in Scratch, follow the given steps:
2 Click on Make a Variable block. Type a
variable name in the New variable name box.
1 Click on Variables
block category.
3 Click on the radio button of either of the 4 Click OK button.
options. Click on For all sprites if you want
this variable to appear for all the sprites.
The variable appears in the list of Variables blocks. Observe that the variable name fruit
appears in all the blocks. Now create the following script.
84 Computer Genius (V2.1)-V

