Page 434 - AI Ver 3.0 class 10_Flipbook
P. 434

Comparison or Relational Operators

              Comparison or relational operators evaluate the values on both sides of the operator and return a Boolean result:
              True if the condition is met and False otherwise. Relational operators used in Python are given below:

                       Name             Symbol                Purpose                  Example             Output
               Equal to                    ==       Returns True if both the  a=16
                                                    values are same.
                                                                                 b=12
                                                                                 a==b                   False

               Not equal to                !=       Returns True if both the  a="Hello"
                                                    values are different.        b="hello"

                                                                                 a!=b                   True

               Greater than                >        Returns  True  if  first  value  Num1=34
                                                    is greater than the second
                                                                                 Num2=23
                                                    value.
                                                                                 Num1>Num2              True
               Less than                   <        Returns True if first value is  Num1=15
                                                    less than the second value.  Num2=10
                                                    Note, strings are compared   Num1<Num2              False
                                                    using their ASCII values.
                                                                                 "Hi">"HI"              True

                                                                                 "67">"621"             True
               Greater than or equal       >=       Returns True if first value is  Num1=5
               to                                   greater than or equals to    Num2=10
                                                    second value.
                                                                                 Num1>=Num2             False
               Less than or equal to       <=       Returns  True  if  first  value  Num1=5
                                                    is less than or equals to
                                                                                 Num2=10
                                                    second value.
                                                                                 Num1<=Num2             True


                            Brainy Fact


                       ASCII  Stands for "American  Standard  Code for Information Interchange." It is a character encoding
                       standard that uses numeric codes to represent characters in upper and lower case, numbers, and
                       punctuation symbols.
                       ASCII value of capital letters A–Z is 65 to 90, small letters is 97 to 122 and numbers 0 to 9 is 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.





                    432     Touchpad Artificial Intelligence (Ver. 3.0)-X
   429   430   431   432   433   434   435   436   437   438   439