Page 106 - TP_Play_V2.1_class6
P. 106

Program 2: To perform all the assignment operators

                      Program2.py
                   File  Edit  Format   Run    Options   Window    Help


                   #example of arithmetic operators
                   a = 21
                   b = 10
                   c = 0

                   c = a + b
                   print(c)
                   c += a
                   print(c)
                   c *= a
                   print(c)
                   c /= a
                   print(c)
                   c %= a
                   print(c)
                   c **= a
                   print(c)
                   c //= a
                   print(c)




                  The output of the above program is:
                      Output

                   31
                   52
                   1092
                   52.0
                   10.0
                   1e+21
                   4.761904761904762e+19



                  Logical Operators


                  Logical operators are used to combine conditional statements as operand. They return either
                  True or False. 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  (x < 5) or (x < 2)           TRUE
                                        is true.
                      not       NOT     It reverses the result, returns false, if   not [(x < 5) and (x < 10)]  FALSE

                                        the result is true or vice versa.


                  104       Play (Ver. 2.1)-VI
   101   102   103   104   105   106   107   108   109   110   111