Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 120 - 2612_Digimind
P. 120

    Combination of variables, constants and operators makes an expression, as shown below:

                                                Operator             Operator

                      Expression:       a           +          5         =          20

                                     Variable              Constant

                      PUNCTUATORS

                      Punctuators are also called separators as they are used to separate lines of codes, variables, etc.
                      The following characters are used as punctuators in Python: ` # \ () [] {} @ , : . ‘ =
                         Brackets []   indicate list.

                         Parentheses ()   indicate tuples, function calls, function parameters for grouping expressions etc.

                         Comma (,)   is used as a separator in a function argument list or variable declaration.
                         Colon (:)   indicates a labelled statement or conditional operator symbol.

                         Equal sign (=)   is used to initialise the value of variable.

                                DATA TYPES

                      Data types are used to define the type of value a data can contain. Each variable in Python is associated
                      with some data type. Each data type requires a different amount of memory and has some specific
                      operations performed on it.
                      Data types are divided into five categories as shown below:

                                                                          Data Types

                                            Numbers          Sets        Mapping       Sequence       Boolean

                                  Integer/long          Float                    String           Lists

                                             Complex                   Dictionary        Tuple

                      NUMBER

                      Numeric data types are used to store numerical values. Python supports three main numeric
                      data types:

                       118  Premium Edition-VII

| 115 116 117 118 119 120 121 122 123 124 125 |