Page 291 - AI Ver 1.0 Class 9
P. 291

a = 5
                                             Returns True if both the values are
               Not equal to          !=                                             b = 10
                                             different otherwise False.
                                                                                     a != b            True
                                                                                     a = 5
                                             Returns True if first value is greater
               Greater than          >                                              b = 10
                                             than second value otherwise False.
                                                                                     a > b             False


                                                                                     a = 5
                                                                                    b = 10

                                                                                     a < b             True
                                                                                 "abc" > "aBc"         True
                                             Returns True if the first value is less
               Less than             <                                                                 True
                                             than second value otherwise False.  "67" > "621"
                                                                                (string value are
                                                                                compared using
                                                                                  ASCII code)



                                                                                     a = 5
                                             Returns  True  if  the  first  value  is
               Greater  than  or    >=       greater than or equals to the          b = 10
               equal to
                                             second value otherwise False.          a >= b             False

                                                                                     a = 5
                                             Returns True if the first value is less
               Less  than    or     <=       than or equals to the second value     b = 10
               equal to
                                             otherwise False.                       a <= b             True




                           Brainy Fact


                  Python  uses  ASCII/Unicode  character  set.  ASCII  Stands  for  "American  Standard  Code  for
                  Information  Interchange."  It  is  a  character  encoding  standard  that  uses  numerical  codes  to
                  represent characters in uppercase and lowercase, numbers and punctuation symbols. ASCII
                  values of capital letters A–Z are 65 to 90, small letters are 97 to 122 and numbers 0 to 9 are 48
                  to 57.




            Logical Operators
            Logical operators are used to combine one or more conditional statements and returns either True or False
            based on the evaluation of the conditions. Following logical operators are provided by Python:

                  Name          Symbol                 Purpose                      Example            Output
                                           Returns True if both the operands
                   AND            and                                            5 < 10 and 2 < 5        True
                                           are True otherwise False.
                                           Returns True if either the operands
                   OR              or                                            5 > 10 or 2 < 5         True
                                           is True otherwise False.


                                                                                Introduction to Python  289
   286   287   288   289   290   291   292   293   294   295   296