Page 69 - Touchcode_C7_Flipbook
P. 69

Step 14:  Drag the ‘splash’ block from ‘Game’, and add ‘join’ block. In join block, write ‘Sum
                            of array is:’ in first part and in second part drag and drop ‘y’ variable.






                  Step 15: Move the ‘splash’ block to ‘on start’ block. Click on the ‘Start the simulator’ button,

                            and the output is:



















                     Well done,  you have learned to calculate the sum of the elements in an array!


                                          Coding fact


                   Mark Zuckerburg, the most well-known computer scientists and the founder
                   of “Facebook”, is credited with his influence over the way you use social media
                   today.


                 HOW CAN WE ITERATE OVER COLLECTIONS?

                 Collections  contains  lists, sets, or maps. There is a lot of  data which  you  can store in
                 collections and as per the program requirement you can perform modifications on the
                 stored data.

                 To perform the modification operation, you need to iterate or traverse the data which is
                 stored in these collections.


                 You can iterate or traverse through  the elements of collection in a sequential  manner.
                 You need to traverse through the elements of collections to fetch the data or make any
                 modifications.

                 MODIFYING COLLECTIONS

                 You cannot modify every collection as there is a limitation on what can be modified in a
                 collection.




                                                                            Understanding Arrays & Collections   67
   64   65   66   67   68   69   70   71   72   73   74