The Python conditional statement learns one, pre-concept preparation code block:
A code block refers to the content of the code that is indented after a colon. The code block defaults to four spaces, which you can indent with the TAB key.
The basic form of the IF condition statement: 1, the basic if statement
The basic if statement is actually basic:
If condition:
The code of the established line
..................
Else
Code for a non-established line
..................
2. Nested IF statements
The nested statement is the IF inside if:
If condition:
If condition 2:
Set up a code block
..................
Else
Code block not established
.....................
Else
Code block not established
..................
3. Multi-Conditional if statement
If condition:
Set up code block 1
..................
Elif Condition 2:
Set up code block 2
..................
Elif Condition 3:
Set up code block 3
..................
..................
Else
Code block not established
..................
4. Pass
The keyword in Python does not perform any action to skip directly. That is useless, but he occupies a block of code, the purpose is to make the code is not wrong, usually before the code is written, the relationship between the judgment or the loop is not fully established, but there is a need to continue the following code. Use pass to occupy the place. The advantage is that the execution of the time will not be an error, or write only if the condition without the code block will be running the code in the event of errors.
Python Conditional Statement Learning