Page 383 - Ai_417_V3.0_C9_Flipbook
P. 383

Following relational operators are provided by Python:

                        Name           Symbol                 Purpose                   Example            Output

                                                                                          a = 5
                                                 Returns True if both the values are
                   Equal to              ==                                              b = 10
                                                 same otherwise False.
                                                                                         a == b             False


                                                                                          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
                                                 Returns True if the first value is less   "abc" > "aBc"    True
                   Less than              <
                                                 than second value otherwise False.
                                                                                      "67" > "621"          True

                                                                                     (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

                                                 Returns True if the first value is less   a = 5
                   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.








                                                                                        Introduction to Python  381
   378   379   380   381   382   383   384   385   386   387   388