Page 61 - ModularV1.1 _c5_flipbook
P. 61

Step 12  Drag             to the slot to set

                            value of Quotient.

                 Step 13  Drag the variable blocks  of
                            N1 and N2 to fit in the slots
                            1 and 2 respectively of the
                            division block.


                 Step 14  Click  on the Flag button to
                            run the program.


                     CONDITIONS

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


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




                                                                                       Advanced Blocks in Scratch  59
   56   57   58   59   60   61   62   63   64   65   66