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

Loops in Python

Loops in Python are control structures that allow for repeated execution of code blocks, primarily using for loops and while loops. The for loop iterates over a sequence, while the while loop continues as long as a specified condition is true. Additionally, Python offers loop control statements like break, continue, and else to manage loop flow.

Uploaded by

suhail789mir
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)
32 views2 pages

Loops in Python

Loops in Python are control structures that allow for repeated execution of code blocks, primarily using for loops and while loops. The for loop iterates over a sequence, while the while loop continues as long as a specified condition is true. Additionally, Python offers loop control statements like break, continue, and else to manage loop flow.

Uploaded by

suhail789mir
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
You are on page 1/ 2

LOOPS IN PYTHON

Loops are control structures in Python that allow you to execute a block of code repeatedly.

There are two main types of loops in Python:

for loop and while loop.

1. for Loop in python

The for loop iterates over a sequence (such as a list, tuple, or string) and executes the block
of code for each item in the sequence until the sequence is exhausted.

Syntax:

for i in range(1,6):

Print(i)

Output

2. While Loop in Python:

The while loop repeats a block of code as long as a specified condition is true. It continues
iterating until the condition evaluates to false.

Syntax:

i=1

while i<=4:

Print(i)

i+=1
OUTPUT

Loop Control Statements in Python

Python provides loop control statements to alter the flow of loops. These include break,
continue, and else statements.

You might also like