Page 139 - Plus_V2.2_C8_Flipbook
P. 139
THE WHILE STATEMENT
The while statement executes a set of statements repeatedly, until the logical expression evaluates
to true. When the condition becomes false, the control comes out of the loop. The syntax of while
statement is given below.
Syntax:
False
while <test expression>: Test Expression
Statements
increment/decrement statement True
Execute while Block
Program 5: To demonstrate the use of a while loop.
You will get the following output:
Tech Fact
Any non-zero value in the while loop indicates always a true condition, whereas zero indicates
always-false condition.
Loops in Python 137

