Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 124 - 2609_Logiccode
P. 124

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

                      LOGICAL OPERATORS

                      Logical operators are used to evaluate and decide. Python supports the following logical operators:

                       Operator Name        Description                                  Example (x=2)            Output

                       and         AND      It returns true, if both conditions are true.  (x < 5) and (x < 10)   True

                       or          OR       It returns true, if one of the conditions is  (x < 5) or (x < 2)      True
                                            true.

                       not         NOT      It reverses the result, returns false, if the  not [(x <  5) and (x  <  False
                                            result is true or vice versa.                10)]

                      Program: To perform all the logical operations.

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

                      122   Premium Edition-VII

| 119 120 121 122 123 124 125 126 127 128 129 |