Page 101 - KEC Khaitan C4 Flipbook
P. 101

COMPARISON/RELATIONAL OPERATORS

                 Scratch  has  three  operators  that  allow you  to  compare  the  relationship  between  two
                 values or variables. It will compare two numbers and decide whether it is true or false.
                 Comparison operators are used with the if... then block.



                              Operator                Meaning                        Examples





                                                                               when     clicked

                                  > 50          Greater than                   if    100  > 50    then
                                                                                 say 100 is greater than 50





                                                                               when     clicked
                                    >  50       Less than                      if     50  < 100    then

                                                                                 say 50 is less than 100





                                                                               when     clicked

                                  = 50          Equals to                      if     50  = 50    then
                                                                                 say Both the numbers are equal




                 LOGICAL OPERATORS
                 Logical operators are used to combine two or more conditions. Logical operators are

                 used when you want to test more than one condition and make a decision. It produces the
                 results by considering if the conditions entered are true or false. In Scratch, there are three
                 logical operators: ‘and’, ‘or’, and ‘not’.



                       Operator                Meaning                               Examples




                                         Logical and               when    clicked


                          and            The result is true if     if     100  > 50  and    100  > 60   then
                                         both the conditions         say 100 is greater than 50 and 60
                                         are true.




                                                                                      Interactivity and Game Design  99
   96   97   98   99   100   101   102   103   104   105   106