Page 92 - TP_Play_V2.1_class5
P. 92

VARIABLES

                  A program is a set of instructions that tell the computer to carry out a task. In
                  scratch, a program is called a Script. A Script is made up of a number of blocks. So,

                  the blocks are the commands or instructions that we give to the sprite to perform
                  a task.
                  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. You can modify this value of a variable 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:

                  Step 1:   Click on Variables block category. A set
                             of blocks appears in the block palette.                                            2

                  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.                                        1

                             Or
                               Click on For this sprite only if you want
                             this variable to appear for this sprite only. Here we have added the variable

                             fruit. It will be available for all the sprites.




                   90       Play (Ver. 2.1)-V
   87   88   89   90   91   92   93   94   95   96   97