0% found this document useful (0 votes)
13 views2 pages

Python Iterative Control Statements Guide

Uploaded by

juseschrist153
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Python Iterative Control Statements Guide

Uploaded by

juseschrist153
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Iterative Control Statements in Python

Iterative control statements are used to repeat a block of code multiple times.

1. FOR LOOP

Used when the number of iterations is known.

Syntax:

for variable in sequence:

statements

Example:

for i in range(1, 6):

print(i)

2. WHILE LOOP

Used when the number of iterations is not known in advance. Runs until the condition becomes
false.

Syntax:

while condition:

statements

Example:

i=1

while i <= 5:

print(i)

i += 1

3. LOOP CONTROL STATEMENTS

break - exits the loop.

continue - skips the current iteration.

pass - does nothing (placeholder).


Example for break:

for i in range(1, 10):

if i == 5:

break

print(i)

Example for continue:

for i in range(1, 6):

if i == 3:

continue

print(i)

You might also like