Professional Documents
Culture Documents
Xi-Cs-For-Loop in Python
Xi-Cs-For-Loop in Python
PYTHON
LOOP/ITERATION STATEMENTS
• Loop in Python provide the capability to execute a set of
statements repeatedly as long as a particular condition remains
true.
• Python provides two types of loop:
for loop
while loop
for loop
The for loop of Python is designed to process the items of any sequence, such as a
list, tuple or a string one by one. It is also called counting loop.
Syntax:
for <variable> in <sequence> :
statements_to_repeat
Examples:
for a in [2,3,4,5]: Output:
print(a) 2
3
4
5
s=0 Output:
for a in range(1,6,2): Sum=9
s=s+a
print(“Sum=“,s)
for loop Programs