Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 139 - 2625 PortGPt V2.1
P. 139

    The output of the above program is:

                          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 operands are      (x < 5) and (x < 10)         TRUE
                                           true.
                           or        OR    It returns true, if one of the operands is  (x < 5) or (x < 2)        TRUE
                                           true.
                           not      NOT    It reverses the result, returns false, if   not [(x < 5) and (x < 10)]  FALSE
                                           the result is true or vice versa.

                      Program 3: To perform all the logical operators.

                     The result of the above program will be:

                                                                                            Introduction to Programming  137

| 134 135 136 137 138 139 140 141 142 143 144 |