Page 135 - Trackpad_V1_Book 7_Flipbook
P. 135

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 space ( ) + _- * / /\ ^ & % # $ {} []! _(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.


                                                          PYTHON TOKENS







                   IDENTIFIERS         KEYWORDS            CONSTANTS           OPERATORS           PUNCTUATORS



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

                     Only alphabet, digits and underscores 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 Global, Var^2, Var 1 and 1var.


                 KEYWORDS

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





                                                                                    Tokens and Data Types in Python  133
   130   131   132   133   134   135   136   137   138   139   140