Second, the flow control while
Third, the process control for
1, if the flow control
1、
2, if a combination of common
1、if
IF " conditional statement " : # conditional statement returned True or False Boolean value of " need to run the code " # execute when the condition statement
When the condition statement and return a True, code execution needs to run, when the whole process if the implementation is completed, if the whole process as well as the code below, continue with the following code
a = 10 b = 100 if b > a: print(a) # 10 c = a + b print(c) # 110
2、if...else...
IF " conditional statement " : # True or False Boolean value returned by the conditional statement " code needs to run 1 " # execute when the condition statement the else : " the code required to run 2 " # execute when the condition is not satisfied statement
When the condition statement and return a True, code execution needs to run 1, does not satisfy the condition statement and returns a False, execution of code needs to run 2. When the entire process if executed, if the whole process as well as the code below, the code continues to execute the following
3, if ... elif ... elif ... else ...
4, if nested
2, while flow control
1、
2, while a combination of common
1、while
2、while...else...
3, while nesting
3, flow control for
1、
2, for a combination of common
1、for
2、for...else...
3, for nesting