Page 111 - Touchpad_Plus_V3.2_Class 5
P. 111

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…then’ and ‘if…then…else’. These statements are provided

                 in Scratch from control category of blocks. The ‘if…then’ 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…then’ 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’…then’ 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…then…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 the presence of 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)
                                               Becomes true  when  the sprite

                                               touches a defined colour
                                                                                                   Sensing block

                                                                                               More on Scratch       109
   106   107   108   109   110   111   112   113   114   115   116