Page 27 - tp_Modula_v2.0
P. 27

On running the above program, you will get the following output:

                     Output

                  False
                  True
                  False
                  True
                  False
                  True




                     PRECEDENCE OF OPERATORS

                 Precedence of operators determines the order in which the operators are executed. The operator
                 precedence in Python is listed in the following table. The highest precedence is at the top.

                                   Operator                                      Name

                        ( )                               Parenthesis

                        **                                Exponent

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

                        ==, !=, >, <, >=, <=              Relational

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

                        and, or, not                      Logical

                        Clickipedia



                         Arithmetic operators have higher precedence over Relational operators.



                     SOME MORE PROGRAMS


                 Program 5: To subtract two numbers entered by the user.

                     Program5.py

                  File  Edit  Format  Run   Options   Window    Help
                  a = int(input('Enter the first number:'))
                  b = int(input('Enter the second number:'))
                  sub = a-b
                  print('Difference of two numbers is', sub)





                                                                            Data Types and Operators in Python    25
   22   23   24   25   26   27   28   29   30   31   32