1. Grammar
If Condition:
Code 1
Code 2
Code 3
(The same distance code as the indentation is the same code block, the code runs from top to bottom, and when a condition is not true, the next condition is run)
Syntax format:
If:
Code 1
Elif:
Code 1
else:
Code 1
If nesting (when an if condition is established, enter the next logical judgment in this condition)
While loop syntax, While loop is also called a conditional loop.
While condition:
Code1
While + broken : break means to terminate the loop of the current layer and execute other code
While True:
Print1
Print2
Break
While + continue: continue means to terminate the cycle and go directly to the next loop
Coutinue do not add the code that executes in the last step of the loop body, meaningless.
While+tag: When tag=false all exits
While+else: The terminal will not display until after the program has finished executing.
the Process Control For loop: Remove multiple values from a type
Default count mode
Step Size The default is 1, set to 2 when 1,3
Python Logic and loop mode