[Python] python if语句使用范例代码 →→→→→进入此内容的聊天室

来自 , 2019-06-06, 写在 Python, 查看 109 次.
URL http://www.code666.cn/view/4a3050ae
  1. #!/usr/bin/python
  2. # Filename: if.py
  3.  
  4. number = 23
  5. guess = int(raw_input('Enter an integer : '))
  6.  
  7. if guess == number:
  8.     print 'Congratulations, you guessed it.' # New block starts here
  9.     print "(but you do not win any prizes!)" # New block ends here
  10. elif guess < number:
  11.     print 'No, it is a little higher than that' # Another block
  12.     # You can do whatever you want in a block ...
  13. else:
  14.     print 'No, it is a little lower than that'
  15.     # you must have guess > number to reach here
  16.  
  17. print 'Done'
  18. # This last statement is always executed, after the if statement is executed
  19.  
  20.  
  21.  
  22. #//python/4458

回复 "python if语句使用范例代码"

这儿你可以回复上面这条便签

captcha