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.
- # Coding: UTF-8
- # Special instructions
- # If/elif/else must start with a colon (:).
- # 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.
- # There is no limit on the number of elif statements
- # However, if it is an empty statement, you must add a pass statement. Otherwise, an error is returned.
- X = raw_input ('Please input some value :')
- Print 'X = ', x
- Print '---------- begin ------------'
- If (int (x)> 100 ):
- Print "x & gt; 100"
- Print "The First statement"
- Elif (int (x)> 50 ):
- Print 'x> 50'
- Print "The Second statement"
- Elif (int (x)> 30 ):
- Pass19 else:
- Print 'x <= 30'
- Print '----------- end -------------'
The preceding section describes the usage of the Python if statement.