Page 78 - 2616_V iCode_C-5
P. 78

All the numbers, text, dates, 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 a 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 options. Click on For         4  Click OK button.
                   all sprites if you want this variable to appear for all the Sprites.



                       76    Premium Edition-V
   73   74   75   76   77   78   79   80   81   82   83