Page 100 - TP-Play_V-2.0_Book-8
P. 100
LOOPS IN PYTHON
09
to learn about:
l The for Statement l The while Statement l The Infinite Loop
l The Jump Statements l Some More Programs
Sometimes, you need to repeat a task multiple time or you may need to repeat the task either a
certain number of times or until a condition is satisfied. In Python, the statements that are used
to repeat a set of instructions are called iterative or looping statements. Looping statements are
very useful and necessary for developing applications.
Python provides two types of looping statements— for and while. The for statement is used
to repeat an instruction or a set of instructions a fixed number of times. Whereas, the while
statement is used to repeat a set of instructions until a condition evaluates to true. Let’s discuss
these constructs in brief.
for each item
THE FOR STATEMENT in sequence
The for statement executes a simple or compound statement for Last item True
reached?
a fixed number of times. The syntax of the for statement is given
below:
False
for <variable> in <iterator>:
Body of for
Statements
Program 1: To print all the days of a week Exit loop
100 Play (Ver. 2.0)-VIII

