Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 106 - 2606_PlugGPT_C7_Flipbook
P. 106

    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 learnt about some tokens in the previous class. Now learn more about them in detail.

                                                               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.

                      KEYWORDS

                      Keywords are the reserved words. They are predefined words. Keywords cannot be used as an
                      identifier.

                      104   Premium Edition-VII

| 101 102 103 104 105 106 107 108 109 110 111 |