Page 143 - TP_Plus_v2.2_Class_8
P. 143
9 Loops in Python
Let’s surf
The for Statement The while Statement
Jump Statements Some More Programs
Let’s PLug-in Century #Information Literacy
21 st
Skills
State whether these statements are true or false.
1. Python does not support conditional statements. ____________
2. We can use if statement inside another if statement. ____________
3. We can check multiple conditions in Python. ____________
Sometimes, you need to repeat a task multiple times 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 statements in brief.
THE FOR STATEMENT
The for loop is a type of iterative statement that allows the user to repeat a set of statements multiple
times until a given condition is falsified. The for loop is commonly used when the number of iterations
is known in advance or when iterating over a sequence, such as a list, string, tuple, or a range.
The syntax of for loop is as follows:
for <counter variable> in range(start, stop,
step_size):
statements
Loops in Python 141

