返回顶部

收藏

Compare integers using if structures, relational operators and equality operators.

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

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 )

标签:Python,Data,Type

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2016-10-03 09:01:46Integer division returns the floor: by 西国の海妖
  2. 2017-03-06 12:51:40Define and use integer by 山药
  3. 2016-02-10 10:32:41Bit calculation: shift left by 风云轩
  4. 2017-03-06 12:57:06Int value demo by 山药
  5. 2016-02-11 10:46:081 is true in Python by Solon.Ring
  6. 2017-03-13 21:15:13Mixed-type conversions by 山药
  7. 2017-04-04 13:23:59oct and hex function by xwz
  8. 2016-05-30 16:25:19hex literals by jack.chen
  9. 2016-08-19 12:10:45In Python any non-zero integer value is true; zero is false. by 山药
  10. 2016-11-11 16:35:20Tools for Working with Lists by 司马
  11. 2016-08-19 12:27:56Complex Number Multiply: the Complex part by 司马

发表评论