Page 12 - Touchcode_C7_Flipbook
P. 12

The common data types are:
                     Data Type                     Used for                      Declaration            Example

                   Integer (int)       It represents whole numbers (zero,  a = 2                    7, 12, 999
                                       positive, negative value, not the

                                       decimal value)/integer value.
                                       Assigning  non-integer  values  to
                                       integer variable returns an error.
                                       Variable holds only a single value.

                   Floating point      It represents a real number with  a=5.1                      3.15, 9.06, 00.13
                   (float)             decimal values or fraction.             a=9.99*8.888

                                       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). a=’z’               97 (in ASCII, 97 is

                   (char)              The syntax  of  declaring  a                                 a lower case 'a')
                                       character variable is specific  to
                                       the programing language.

                                       It is the smallest data type by size.
                                       Assigning  a non-character type
                                       value to character type  variable
                                       returns error.

                   String (str)        It     represents      alphanumeric  a=“Hello”               hello world, Alice,
                                       characters and stores sequence                               Bob123
                                       of characters.

                                       It is used for the combination of
                                       any character which appears on
                                       the  keyboard  (letters, numbers,

                                       symbols).

                                       In python string variables can be
                                       declared either by single quotes
                                       or double quotes or triple quotes.

                   Boolean (bool)      It represents logical values.           b=False              TRUE, FALSE
                                       It stores values in Boolean type
                                       only i.e. “true (1)” or “false (0)”.

                                       It is a subtype of integer data type.



                   10     Touchcode-VII
   7   8   9   10   11   12   13   14   15   16   17