''' 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 # We are setting all these b_ variables to a boolean! # A boolean is a logical value (True/False) # We can set a variable equal to a boolean by giving it a # comparison (like a < b) and True/False will be stored in the boolean # based on what the comparison is (True/False) # Numbers are compared as normal but for strings (alphanumeric # characters), a < z so "ab">"aa" and "abc" > "abb" b1 = ( a < b ) # < is less than # Python will evaluate the expression to True / False # The value of the expression (the comparison you're making) # will be True/False (evaluated to True/False) and the value # True/False will be stored as a result of that comparison # into the variable! # if ( condition / expression ): # condition/expression will be True/False b2 = ( a > b ) # > is greater than b3 = ( a <= b ) # <= is less than or equal to b4 = ( a >= b ) # >= is greater than or equal to b5 = ( a == b ) # == is equals b6 = ( a != b ) # != is not equals # 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()