Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 111 - 2606_PlugGPT_C7_Flipbook
P. 111

    Operator Precedence
                     An arithmetic expression without parentheses will be evaluated from left to right using the rule of

                     precedence of operators.

                            Priority                Operator                                 Name

                              First                       ()                               Parenthesis

                             Second                       **                                 Exponent

                              Third                    *, /, %, //         Multiplication, Division, Modulus, Floor Division
                             Fourth                      +, –                          Addition, Subtraction

                               Fifth               ==, !=, >, <, >=, <=                    Comparison

                              Sixth            =, +=, -=, *=, /=, %=, **=, //=             Assignment

                             Seventh                 not, and, or                             Logical

                     Write a program to use operators in Python.

                                         Which type of applications can be developed in Python?

                     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.

                                                                                        Tokens and Data Types in Python  109

| 106 107 108 109 110 111 112 113 114 115 116 |