Home>Article>Backend Development> What does while mean in python

What does while mean in python

silencement
silencement Original
2019-06-27 13:49:49 22823browse

What does while mean in python

In Python programming, the while statement is used to execute a program in a loop, that is, under certain conditions, execute a certain program in a loop to handle the same task that needs to be processed repeatedly. Its basic form is:

while Judgment statement:

Execution statement...

For example

a = 1 while a <= 10: print(a) a += 2

Output result

1 3 5 7 9

The meaning of this code is: the initial value of a is 1, and the judgment condition is: if a <10, then print a, Then add 2 to the returned a. If a<10, the program will be executed forever; if a is not less than 10, the program will be terminated. Obviously, the value of a returned for the fifth time is 9, 9 plus 2 equals 11, 11 is not less than 10, and the program terminates.

The above is the detailed content of What does while mean in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn