''' Purpose: introduce relational operators ''' # get two numbers from user print() sa = input( 'Enter number: ' ) sb = input( 'Enter number: ' ) print() # convert inputs to integer a = int( sa ) b = int( sb ) # compare and record results b1 = ( a < b ) # < is less than b2 = ( a > b ) # > is greater than b3 = ( a <= b ) # <= is less than or equal to b4 = ( a >= b ) # >= is greater than or equal to # has to be >=, cannot be => , python does not recognize that. we say less than or equal, not equal or less than b5 = ( a == b ) # == is equals b6 = ( a != b ) # != is not equals # what is handed back from these operators? -> True or False # True and False are kind of like keywords, they aren't strings, or numbers, or lists, or anything that we've seen # these are literal values, and they are special logical or bool (boolean) values of True and False # note: python is built on C++, which is built on C. weird behavior is inherited: # numbers: anything but 0 is True ( 0 is false ) # strings: anything but "" is True ( if Rachel has her facts straight ) # these operators work on strings and numbers. strings do alphabetical comparison, similar to max() and min() # sometimes the operators work on lists but let's not worry about that for now # True and False are opposites. # display results print( a, '< ', b, ':', b1 ) print( a, '> ', b, ':', b2 ) print() print( a, '<=', b, ':', b3 ) print( a, '>=', b, ':', b4 ) print() print( a, '==', b, ':', b5 ) print( a, '!=', b, ':', b6 ) print()