Page 71 - Computer_Genius_v2.1_C7_flipbook
P. 71

exercise




                 A.  Tick ( ) the correct option.
                    1.  Which type of block runs a code a specific number of times?

                         (i)  forever block                               (ii)  while block

                        (iii)  break block                               (iv)  repeat block
                    2.  The forever loop is mainly used for:

                         (i)  Running code only once

                        (ii)  Running code until a condition becomes false
                        (iii)  Repeating an action a specific number of times

                        (iv)  Continuously running a block of code without stopping

                    3.   The break statement is used to:
                         (i)  Skip to the next iteration of a loop

                        (ii)  Exit a loop before it completes

                        (iii)  Repeat a block of code a specific number of times

                        (iv)  Continuously run a block of code without stopping
                    4.  Parameters in a function are:

                         (i)  Actual values passed to the function

                        (ii)  Variables defined in the function's definition
                        (iii)  Loops that run continuously

                        (iv)  Statements that exit loops early

                    5.  In MakeCode Arcade, functions are used for:
                         (i)  Repeating blocks of code                    (ii)  Stopping loops

                        (iii)  Organising and reusing code               (iv)  Changing the flow of loops


                 B.  Fill in the blanks using the words given below.
                                             Forever   Loop   While   Function   Break

                    1.                     runs a statement or group of statements multiple times till the given condition is
                        true.
                    2.  The                    loop runs if a specified condition is true.
                    3.                     loop is often used for actions that need to happen repeatedly without stopping.

                    4.                     statement is used to come out of a loop early when the specific condition is met.
                    5.                     help to organise code, make it reusable, and improve readability.




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