Page 63 - Computer - 6
P. 63

Operators Blocks
          The Operators blocks let you work with various operators. These blocks are colour-code green. These
          are reporter blocks that fit into similar-shaped slots of other blocks. There are several types of operators
          blocks in the Operators blocks palette. Let us learn about some of them.

          Mathematical Operator Blocks
          Mathematical  operators  are  used  to  perform  mathematical  calculations  on  numeric  values.  The
          mathematical operator blocks in Scratch 3 are:

                 Block                                              Description
                              Adds the two specified values.

                              Subtracts the second value from the first value.
                              Multiplies the specified values.

                              Divides the first number by the second number and displays the quotient.

                              Divides the first number by the second number and displays the remainder.
          Relational Operator Blocks
          Relational operators are used to compare two values or expressions. The result of these operators is
          either True or False.
          The relational operator blocks in Scratch 3 are:

                 Block                                              Description

                              Returns ‘True’ if the first value is equal to the second value, else returns ‘False’.
                              Returns ‘True’ if the first value is greater than the second value, else returns ‘False’.

                              Returns ‘True’ if the first value is less than the second value, else returns ‘False’.

          Logical Operator Blocks
          Logical operators are used to combine two or more expressions containing relational operators. These
          operators evaluate to either True or False. The logical operator blocks in Scratch 3 are:

                 Block                                              Description

                              Returns ‘True’ if both the expressions are True, else returns ‘False’.
                              Returns ‘True’ if any one of the expressions is True, else returns ‘False’.
                              Returns ‘True’ if the expression is False and returns ‘False’ if the expression is True.
                              (Reverses the result of the expression)

          The table given below illustrates the use of the logical operators taking the values X = 25, Y = 40, and
          Z = 30 as example.

                        Expression                              Evaluation                          Result
                      X < Y AND Y > Z                         True AND True                          True
                      X > Y AND Y > Z                        False AND True                          False

                      X > Y OR Y > Z                          False OR True                          True
                      X > Y OR Y < Z                          False OR False                         False
                        NOT X > 30                              NOT False                            True


                                                                                                              61
   58   59   60   61   62   63   64   65   66   67   68