Topic: Iterative Statements in Python
OR
Subtitle: Loops in Python Programming
Created by :
Kashiram Bilhriya PGT CS
KV-2 KRIBHCO, SURAT
Introduction to Iteration
Meaning of iteration: Repeating a set of instructions until a condition is met.
Importance in programming
Example from real life: Walking until reaching home
Types of Iteration in Python
The while Loop
Syntax:
initialization
while (condition):
statements
increment or decrement
Loop continues until condition becomes false
Example of while Loop
count = 1
while count <= 5:
print("Hello")
count += 1
Output:
Hello
Hello
Hello
Hello
Hello
The for Loop : Used for definite iteration.
Syntax:
for variable in sequence:
statements
Example of for Loop
for i in range(1, 6):
print(i)
Output:
1
2
3
4
5
Control Statements
break → exit loop immediately
continue → skip current iteration, go to next
Summary :
Iteration avoids repetition of code.
Python provides while and for loops.
Control statements (break, continue) enhance loop control