Page 76 - TechPluse_C4_Flipbook
P. 76

Logical Operators

                  Using logical operators, you can combine two or more relational operators to produce a single
                  true/false result. These blocks allow you to further refine your comparison of values.


                            Operator                                          Meaning

                                                 The result is true only if the two expressions are true.
                   1.  AND

                                                 The result is true only if either of the expressions is true.
                   2.  OR

                                                 The result is true only if the expressions is false.
                   3.  NOT


                      VARIABLES


                  Variables are used to hold values. These are the data values for which
                  the value can be changed when the code is being processed. There
                  are two ways in which the values can be assigned to the variables—

                  by the programmer and by the user.
                  Each programming language has a method or syntax for defining

                  variables. In Scratch, the variables can be created using Variables
                  blocks.
                  To create a variable, follow these steps:

                  Step 1    Click on Variables category of blocks.

                  Step 2    Click on  Make a Variable button  to open the  New
                            Variable dialog box.
                                                                                                   Variables block
                  Step 3    Type a suitable name, for example N1 for the variable in
                            the New variable name text box.
















                                                          New variable dialog box

                  Step 4    Select an option specifying whether  the variable  is to be
                            created For all sprites or For this sprite only.

                  Step 5    Click on OK button.


               74       Premium Edition-IV
   71   72   73   74   75   76   77   78   79   80   81