Page 292 - AI Ver 1.0 Class 9
P. 292

not(5 > 10 or 2 < 5)     False
                                       Returns True if the operand is False.
               NOT             not                                              not(10 < 5)          True
                                       It reverses the result.
                                                                                 not(True)           False




                        Brainy Fact


             In case of OR operator, the second condition is checked only if the first is False otherwise it ignores
             the second operand.




        Assignment Operator

        Assignment operator is used to assign a value to a variable or a constant. = sign is used as an assignment
        operator in Python. For example,

           rollno = 12

          myname = "Alisha"
          mymarks = 92.5
        Augmented Assignment Operators
        Augmented assignment operators are those operators which take the value of the operand on the right side,
        perform an operation and assign the result to the operand on the left side. These operators are also known as
        shorthand assignment operators. For example, if a=10 then a+=5 is the same as a=a+5.

        Python provides the following augmented assignment operators:


               Symbol                          Purpose                         Example            Output
                                                                                 a = 5

                             Adds first and then assigns the result to the left-  b = 10             15
                  +=
                             hand side operand.                                 a += b               20

                                                                                 a += 5
                                                                                 a = 5
                             Subtracts first and then assigns the result to the
                  -=                                                             b = 10              -5
                             left-hand side operand.
                                                                                 a -= b
                             Multiplies first and then assigns the result to the   a = 5
                  *=                                                                                 25
                             left-hand side operand.                             a *= 5
                             Divides first and then assigns the result to the    b = 10
                  /=                                                                                2.0
                             left-hand side operand.                             b /= 5
                                                                                 a = 5
                             Floor division first and then assigns the result to
                  //=                                                            b = 10              2
                             the left-hand side operand.
                                                                                b //= a




                  290   Touchpad Artificial Intelligence-IX
   287   288   289   290   291   292   293   294   295   296   297