if else conditional statement
single branch
if condition: code to be executed when the condition is met
double branch
if condition: Execute code when conditions are met else: If the condition is not met, go to this section
multi-branch
if condition: Execute code when conditions are met elif condition: If the above conditions are not met, go for this elif condition: If the above conditions are not met, go for this elif condition: If the above conditions are not met, go for this else: If all the above conditions are not met, go to this section
while loop
while condition: Execute code...
loop termination statement
- break is used to completely end a loop and jump out of the loop body to execute the statements after the loop
- continue is similar to break, the difference is that continue only terminates the current loop, and then executes the following loop, while break terminates the loop completely
while....else.....
When the while loop is executed normally and is not interrupted by break in the middle, the statement following the else will be executed.
flag bit
A control loop is achieved by modifying the flag bits
exit_flag = False while not exit_flage: ....... exit_flage = True
single branch
if condition: code to be executed when the condition is met
double branch
if condition: Execute code when conditions are met else: If the condition is not met, go to this section
multi-branch
if condition: Execute code when conditions are met elif condition: If the above conditions are not met, go for this elif condition: If the above conditions are not met, go for this elif condition: If the above conditions are not met, go for this else: If all the above conditions are not met, go to this section
while loop
while condition: Execute code...
loop termination statement
- break is used to completely end a loop and jump out of the loop body to execute the statements after the loop
- continue is similar to break, the difference is that continue only terminates the current loop, and then executes the following loop, while break terminates the loop completely
while....else.....
When the while loop is executed normally and is not interrupted by break in the middle, the statement following the else will be executed.
flag bit
A control loop is achieved by modifying the flag bits
exit_flag = False while not exit_flage: ....... exit_flage = True