Page 105 - CG_v2.1_flipBooks_class_6
P. 105

In the previous class, you learned about the introduction to coding and MakeCode Arcade. In this
                 class, you are going to learn more about MakeCode Arcade.

                 What are Variables?

                 You  have  seen  your  mother  naming  boxes  in  the  kitchen.
                 That box has a little storage capacity and your mother gave
                 it a name such as salt, sugar, tea, etc. Similarly, a variable
                 is a name given to a location in the computer’s memory to
                 store values or data. A variable has a name (for reference),
                 a type (which defines the kind of data it can store and its
                 size), and a value (the actual data).

                 Naming Variables

                 Each variable in a program must have a unique name; you cannot use the same name for more than
                 one variable. The name of a variable serves as an identifier.

                 Rules for Naming a Variable
                 Some rules for naming a variable are as follows:

                    Name your variables in such a way that it describes their purpose.
                    Variable names must begin with a letter or an underscore.

                    No special characters or spaces are allowed in variable names.
                    Uppercase and lowercase characters are distinct.

                    Keywords (reserved words) cannot be used as a variable name. A keyword is a predefined word in
                   any programming language.
                 Creating Variable

                 In MakeCode Arcade, we can create a variable using the Variables block category. Once a variable
                 is created, you need to assign a value to it. This process of assigning a value to a variable is called
                 initialisation. To create and initialise a variable in MakeCode Arcade, follow these steps:


                                                  1  Visit https://arcade.makecode.com/.













                          2  Click on the New
                         Project button. The
                         Create a Project
                         dialog box appears.




                                                                                  More on MakeCode Arcade     103
   100   101   102   103   104   105   106   107   108   109   110