Page 86 - Computer Genius Class 05
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 e can get in ormation rom it later. This data
is stored in variables. t is called aria le ecause it does not ha e a fixed alue its alue
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 t o types o aria les. They are as ollo s
Global Variables
a aria le is created to e used and modified y all the sprites then it is no n as a glo al
variable. A Global variable can be created on any sprite but its value can be accessed or
modified y other sprites used in the pro ect.
Local Variables
a aria le is created to e used and modified y a single sprite only then it is no n as a local
aria le. ocal aria les can only e accessed or modified rom the sprite here it as created.
Creating Variables in Scratch
To create aria les in cratch ollo the gi en steps
2 Click on Make a Variable loc . 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 aria le appears in the list o Variables blocks. Observe that the variable name fruit
appears in all the blocks. Now create the following script.
84 Computer Genius-V

