May 10, 2021 Python2
This section introduces you to Python's circular statements, which are generally executed sequentially.
Programming languages provide a variety of control structures that allow for more complex execution paths.
Loop statements allow us to execute a statement or group of statements more than once, as follows in general form of circular statements in most programming languages:
Python provides for loops and while loops (there is no do. While loop):
The type of loop | Describe |
---|---|
While loop | The loop body is executed when the given judgment condition is True, otherwise the loop body is exited. |
For loop | Repeat the statement |
Nested loops | You can nest the for loop in the while loop body |
Loop control statements can change the order in which statements are executed. Python supports the following loop control statements:
The control statement | Describe |
---|---|
Break statement | Terminates the loop during statement block execution and jumps out of the entire loop |
The continue statement | Terminates the current loop during statement block execution, jumps out of the loop, and executes the next loop. |
Pass statement | Pass is an empty statement to maintain the integrity of the program structure. |