Page 31 - Touchcode_C6_Flipbook
P. 31

Coding           uiz   01

                                                                                                      Subject Enrichment
                    State whether the following statements are true (T) or false (F).

                    a.  Part of the code in which the variable can be used is scope.

                    b.  Variable name must begin with a special character.



                 DATA TYPES
                 Variables contain the values on which the operations are performed. Every variable needs
                 to be assigned to a specific data type to make it accessible for the computer.
                 Data type  identifies  the type  of  data which  the  declared  variable can  hold.  It  helps  the
                 computer to understand what operations need to be performed on the declared variables.
                 The common data types are:

                    Data Type                        Description                      Declaration       Example
                  Integer (int)        It  represents  whole  numbers  (zero,  x=4                    5, 10, 988
                                        positive, negative value, but not decimal
                                        (fractional) values.
                                       Assigning non-integer value to integer
                                        type variable returns error.
                                       Integer type variable holds only a single
                                        value.

                  Floating Point       It represents real numbers with decimal  x= 5.1                4.65, 8.05,
                  Numbers               values or fractions.                          x= 9.99*8.88 10.1
                  (float)              Another type of floating-point number is
                                        'double' data type, to store even bigger
                                        values.
                  Character            It holds a single letter. (e.g., a.b.c.)       x='y'           90 (in ASCII,
                  (char)               The syntax of declaring a character type                       90 is a
                                        variable is specific to the programing                        upper case
                                        language.                                                     'Z')
                                       It is the smallest data type by size.
                                       Assigning a non-character type value to
                                        a character type variable returns error.
                  String (str)         It represents alphanumeric characters  x= 'Orange'             Coding,
                                        and stores sequence of characters.                            Fruit,
                                       It is used for combination  of any                             Orange123
                                        character which  appears on  keyboard
                                        (letters, numbers, symbols).
                                       In  python  string  variables can  be
                                        declared either by single  quotes or
                                        double quotes or triple quotes.



                                                                                 Variables Using  Block Coding   29
   26   27   28   29   30   31   32   33   34   35   36