Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 136 - 2505_CoreGPT(Podar)_Flipbook_C5
P. 136

    When the condition is to be checked, it is called taking a decision. The statements

                      that are executed on the basis of decisions taken from a choice are called conditional
                      statements.

                      The conditional statement used in Scratch is the ‘if’ statement. The ‘if’ statement
                      has two  variants  —‘if…’  and  ‘if…else’. These statements are  provided  in
                      Scratch  from control  category  of blocks. The  ‘if…’ block checks the given

                      condition. If the condition is  true,  the code inside the
                      C (space)  will be activated.  If the condition is  false, the
                      control will come out of the ‘if…’ block and move to the

                      next blocks in the sequence.

                      Suppose, we want to check whether a person is a senior citizen
                      or not. The code for this can be defined using ‘if…' as:

                                                      But this code does not give an output if the age of the
                                                      person is less than or equal to 60 years.
                                                      For such situations, when two different outputs are to

                                                      be specified for two conditions, we use ‘if…else’ block.
                                                      In this block, if the condition is true, the code inside the
                                                      first C (space) will be activated. If the condition is false,

                                                      the code inside the second C (space) will be activated.

                            SENSING BLOCKS

                      The blocks in the Sensing category help the selected sprite to

                      detect other sprites or other elements on the stage including the
                      edges of the stage. The blocks in the Sensing category are colour
                      coded as light blue.

                      Some of the blocks included in the Sensing category are shown
                      along side.

                      The Table below shows some important sensing blocks and their
                      functions.

                                                   Becomes true when the sprite touches the
                                                   mouse pointer or the edge of the stage
                                                   (defined by clicking on the drop-down

                                                   arrow)

                                                                                                           Sensing block

                    134     Premium Edition-V

| 131 132 133 134 135 136 137 138 139 140 141 |