Page 112 - Trackpad_V5_Book 8
P. 112
THE while LOOP
The while loop repeats a block of statements for a given number of times, until the control condition
is false. In this looping construct, first, the condition is checked and if it is true, the control will move
inside the loop and execute the statements until the condition becomes false. If the initial condition
is false then the control will not enter the loop block. The syntax of while loop is as follows:
while(loop - condition):
statement(s)
Program 7: To add first five natural numbers.
You will get the following output:
JUMP STATEMENTS
These statements are used to jump out of the loop iterations even if the condition has not become
false. They alter the flow of control unconditionally. The jump statements defined in Python are
break and continue.
THE break STATEMENT
The break statement is used in the for and while loops to terminate the loop and completely
transfer the control from the loop to the next statement after the body of the loop. It is mostly used
when we need to exit from a loop at times.
Program 8: To demonstrate the use of break statement.
110 Pro (Ver. 5.0)-VIII

