Python if statement source code analysis

Source: Internet
Author: User

The Python if statement has many applications in the Python programming language environment, and many programmers cannot use it smoothly, next we will look at the source code to see how the Python if statement can be mastered.

 
 
  1. # Coding: UTF-8
  2. # Special instructions
  3. # If/elif/else must start with a colon (:).
  4. # The expression below the line if/elif/else must have at least one space indent, indicating that this statement is part of the if statement.
  5. # There is no limit on the number of elif statements
  6. # However, if it is an empty statement, you must add a pass statement. Otherwise, an error is returned.
  7. X = raw_input ('Please input some value :')
  8. Print 'X = ', x
  9. Print '---------- begin ------------'
  10. If (int (x)> 100 ):
  11. Print "x & gt; 100"
  12. Print "The First statement"
  13. Elif (int (x)> 50 ):
  14. Print 'x> 50'
  15. Print "The Second statement"
  16. Elif (int (x)> 30 ):
  17. Pass19 else:
  18. Print 'x <= 30'
  19. Print '----------- end -------------'

The preceding section describes the usage of the Python if statement.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.