Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 118 - 2612_Digimind
P. 118

    PYTHON CHARACTER SET

                      A set of valid characters recognised by a language is called a character set. The characters used
                      in the Python source program belong to the Unicode standard. The characters in Python are
                      grouped into the following categories:

                         Alphabet:  A to Z (uppercase), a to z (lowercase)

                         Digits: 0 to 9

                         Special characters (:) colon ( ) + _- * / /\ ^ & % # $ {} []! _(underscore) >< ?@ , ; etc. (white space,
                        blank space, horizontal tab ( ), carriage return, new line, form feed)

                      Python can process any of the ASCII and Unicode characters as data or as literals.

                                PYTHON TOKENS

                      A token  is the smallest  element  of a Python  program that  is meaningful to  the interpreter.

                      You have learned about some tokens in the previous class. Now learn more about them in detail.
                      They are classified into the following types:

                                                               PYTHON TOKENS

                        IDENTIFIERS         KEYWORDS            CONSTANTS           OPERATORS            PUNCTUATORS

                      IDENTIFIERS

                      An identifier is a sequence of characters taken from the Python character set. It refers to variables,
                      functions and arrays. The rules for identifiers are:

                         Only letters, digits and an underscore are permitted.

                         Must start with a letter between A to Z or between a to z or an underscore (_).

                         Uppercase and lowercase are distinct because Python is a case sensitive language.

                         Special characters are not allowed.
                      Some examples of valid identifiers are Myvar, myvar_1, Sum_of_the_numbers, PASS and _Sum.

                      Some examples of invalid identifiers are False, Var^2, Var 1 and 1var.

                       116  Premium Edition-VII

| 113 114 115 116 117 118 119 120 121 122 123 |