Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 86 - 2607_Trackpad_Pro_5.1_flipbook_C7
P. 86

    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) >< ?@ , ;

                       White space: Blank space, horizontal tab, carriage return, new line, form feed, etc.
                     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 the Python character set. It refers to the
                     name of a variable, function, array, etc. The rules for identifiers are:

                       Only letters, digits and an underscore are permitted.

                       Must begin with a letter from A to Z, or a to z, or an underscore (_).
                       Uppercase and lowercase are distinct because Python is a case sensitive language.

                       Special characters are not allowed.

                                            Valid                               Invalid
                                          identifiers                         identifiers

                                    Myvar                     False (keywords are not allowed)

                                    myvar_1                   Var^2 (special characters are not allowed)

                                    PASS                      Var 1 (first character must be letter)

                                                                                        Tokens and Data Types in Python  85

| 81 82 83 84 85 86 87 88 89 90 91 |