Page 89 - TP_Modular_V2.1_Class6
P. 89

Operator       Name                       Description                        Example       Output
                                                                                          (x=8 and y=6)
                     >=         Greater    It checks if the value of left operand is greater   x >= y       TRUE
                                than or    than or equal to the value of right operand. If
                               equal to    yes, then the condition becomes true.
                     <=        Less than  It checks if the value of left operand is less       x <= y       FALSE
                              or equal to than or equal to the value of right operand. If
                                           yes, then the condition becomes true.

                 Program 4: To show all the relational operators’ functions
                     Program4.py
                  File  Edit  Format    Run   Options   Window    Help

                   #Program to perform Relational Operators
                   a = 11
                   b = 32
                   #Check if a is greater than b
                   print (a > b)
                   #Check if a is less than b
                   print (a < b)
                   #Check if a is equal to b                                       Output
                   print (a == b)                                                False
                   #Check if a is not equal to b
                                                                                 True
                   print (a != b)
                                                                                 False
                   #Check if a is greater than equal to b
                   print (a >= b)                                                True
                   #Check if a is ess than equal to b                            False
                   print (a <= b)
                                                                                 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

                        ()                                 Parentheses

                        **                                 Exponent

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

                        +, –                               Addition, Subtraction

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

                        and, or, not                       Logical



                                                                               Introduction to Programming        87
   84   85   86   87   88   89   90   91   92   93   94