Compare integers using if structures, relational operators and equality operators. : integer « Data Type « Python Tutorial






# read first string and convert to integer
number1 = raw_input( "Please enter first integer: " )
number1 = int( number1 )

# read second string and convert to integer
number2 = raw_input( "Please enter second integer: " )
number2 = int( number2 )

if number1 == number2:
   print "%d is equal to %d" % ( number1, number2 )

if number1 != number2:
   print "%d is not equal to %d" % ( number1, number2 )

if number1 < number2:
   print "%d is less than %d" % ( number1, number2 )

if number1 > number2:
   print "%d is greater than %d" % ( number1, number2 )

if number1 <= number2:
   print "%d is less than or equal to %d" % ( number1, number2 )

if number1 >= number2:
   print "%d is greater than or equal to %d" % ( number1, number2 )








2.10.integer
2.10.1.To denote an octal literal, use 0 followed by a sequence of octal digits (0 to 7).
2.10.2.Simple addition program.
2.10.3.Compare integers using if structures, relational operators and equality operators.
2.10.4.X // Y: Floor division truncates fractional remainders down to their floor