Page 96 - PlugGPT_V2.0_C7_Flipbook
P. 96

Program 4: To show all the relational operators’ functions

                      Program4.py
                   File  Edit  Format   Run    Options   Window    Help


                   #example of arithmetic operators
                   a = 11
                   b = 32

                   #Check if a is greater then b
                   print(a > b)
                   #Check if a is less then b
                   print(a < b)
                   #Check if a is equal to b
                   print(a == b)
                   #Check if a is not equal to b
                   print(a != b)
                   #Check if a is greater then equal to b
                   print(a >= b)
                   #Check if a is less then equal to b
                   print(a <= b)




                  The result of the above program is:

                      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 given table. The highest precedence is at the top.


                                    Operator                                      Name
                         ()                                 Parentheses

                         **                                 Exponent

                         *, /, %, //                        Multiplication, Division, Modulus, Floor Division

                         +, –                               Addition, Subtraction

                         ==, !=, >, <, >=, <=               Comparison
                         =, +=, -=, *=, /=, %=, **=, //=    Assignment

                         and, or, not                       Logical




               94       Premium Edition-VII
   91   92   93   94   95   96   97   98   99   100   101