Page 95 - modular4.0
P. 95

Chapter Profile
                  Operator      Name                       Description                       Example        Output
                                                                                           (x=8 and y=6)


                     <=       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
                    print (a == b)                                                Output
                    #Check if a is not equal to b
                                                                               False
                    print (a != b)
                                                                               True
                    #Check if a is greater than equal to b
                                                                               False
                    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  93
   90   91   92   93   94   95   96   97   98   99   100