Page 64 - Touchcode_C7_Flipbook
P. 64

Advantage of array is that it improves readability of code by using a single variable for a
                  large set of data.  But there are limitations of using an array too, which are:
                      Variables of same data types can be stored in an array

                      The variables in an array are ordered sequentially with ‘0’ as the starting index

                  Declaration of array with variables of string data type is:
                  arr = [‘AB’, ‘CD’, ‘EF’, ‘GH’, ‘IJ’, ‘KL’];

                  Explanation:

                  An array named ‘arr’ is declared with the data type as string i.e the declared array (arr) can
                  only hold string values.

                  We have initialized the array (arr) with six values i.e AB, CD, EF, GH, IJ, KL.

                             AB       CD        EF       GH         IJ      KL

                             0         1        2         3        4         5                Array Indices

                         Array Length = 6
                         First Index = 0

                         Last Index = 5



                                                                                                    Experiential Learning
                                                       Coding Task            02



                                           To create an array and calculate its length
                   In this task you will learn to create an array and calculate its length in MakeCode Arcade.

                   To perform the task, follow these steps:

                   Step 1:  Visit the link: https://arcade.makecode.com/. Create a project ‘Array’ and click on
                             ‘Create’.

                   Step 2:   Click on the variables, and select ‘Make a variable’ block. Create a variable ‘a’.





















                   62     Touchcode-VII
   59   60   61   62   63   64   65   66   67   68   69