Page 125 - KEC Khaitan C3 Flipbook
P. 125

In such situations, you will use conditional blocks. Scratch has two conditional blocks
                 in Control blocks category. They are:


                 1.   If,then...block: This block executes the commands inside it
                     only if the specified condition is true. If the condition is false,

                     the commands within the block are not executed, and only
                     the commands outside the block will run.


                 2.   If,then,..else block: This block runs the commands inside the
                     Then section if the condition is true. If the condition is false, it

                     executes the commands in the “Else” section instead.



                           VARIABLES


                 A program is a group of commands and 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 you give to the

                 Sprite to perform a task.

                 All the numbers, text, dates, or pictures that you use in a program are called data.
                 You store this data in the computer memory so that you 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.










                                                                                             Interactivity and Logic  123
   120   121   122   123   124   125   126   127   128   129   130