1 of 9

Topic: Iterative Statements in Python

OR

Subtitle: Loops in Python Programming

Created by :

Kashiram Bilhriya PGT CS

KV-2 KRIBHCO, SURAT

2 of 9

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

3 of 9

Types of Iteration in Python

  • Entry controlled loops: for, while
  • Infinite loops (unintended if condition never fails)

4 of 9

The while Loop

Syntax:

initialization

while (condition):

statements

increment or decrement

Loop continues until condition becomes false

5 of 9

Example of while Loop

count = 1

while count <= 5:

print("Hello")

count += 1

Output:

Hello

Hello

Hello

Hello

Hello

6 of 9

The for Loop : Used for definite iteration.

Syntax:

for variable in sequence:

statements

7 of 9

Example of for Loop

for i in range(1, 6):

print(i)

Output:

1

2

3

4

5

8 of 9

Control Statements

break → exit loop immediately

continue → skip current iteration, go to next

9 of 9

Summary :

Iteration avoids repetition of code.

Python provides while and for loops.

Control statements (break, continue) enhance loop control