Page 110 - CG_v2.1_flipBooks_class_6
P. 110

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.



















                      108    Computer Genius (V2.1)-VI
   105   106   107   108   109   110   111   112   113   114   115