Page 71 - ThinkGPT_V2.1_C7_Flipbook
P. 71

Using Logic Blocks

                 In  MakeCode  Arcade,  logic  blocks are  used  to  handle  decision-making  and  control  flow  in  your
                 projects. We can access these blocks by clicking on the Logic blocks category. The Logic blocks are
                 divided into three types:

                    Conditionals: These blocks, also known as decision-making blocks, are fundamental constructs in
                   programming that allow a program to make decisions and execute different blocks of code based on
                   certain conditions. There are two conditional blocks in MakeCode Arcade, which are as follows:

                            Block               Name                            Description


                                                             Allow us to execute code only if a certain condition
                                           if-then
                                                             is true.




                                                             Allow us to execute one block of code if a condition
                                           if-then-else      is true, and a different block of code if the condition
                                                             is false.



                   Comparison: These blocks help you compare values. By default, MakeCode Arcade shows only
                   three comparison blocks, which are as follows:

                                 Block                        Name                        Description


                                                                                Return true if both the numbers
                                                     equal
                                                                                are equal.

                                                                                Return true if the first number
                                                     Less than
                                                                                is less than the second number.

                                                                                Return  true  if both  the  text
                                                     equal (for text)
                                                                                values are equal.



                     However, when we click on the down arrow of these blocks, we will get more comparison options
                   like not equal to, greater than, greater than or equal to, and less than or equal to.



















                                                                                  More on MakeCode Arcade     69
   66   67   68   69   70   71   72   73   74   75   76