0% found this document useful (0 votes)
3 views18 pages

Loop in Python

The document provides an introduction to loops in Python, explaining their purpose as a structure that repeats instructions until a condition is met. It covers different types of loops, including for loops and while loops, and emphasizes the importance of indentation in nested loops. Additionally, it includes examples and flow charts to illustrate the concepts discussed.

Uploaded by

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

Loop in Python

The document provides an introduction to loops in Python, explaining their purpose as a structure that repeats instructions until a condition is met. It covers different types of loops, including for loops and while loops, and emphasizes the importance of indentation in nested loops. Additionally, it includes examples and flow charts to illustrate the concepts discussed.

Uploaded by

Kabir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Loop in Python

Course: Introduction To Programming


Agenda
Loop

List in Python 2
Loop
Loop

• A loop is a programming structure that repeats a set of


instructions until a specified condition is met.
For E.g.

• I want to write my
name 10 times so
what ways I can
achieve this.
E.g.(continue)

• I develop a way in which I can revisit my code multiple


time
Here is the Solution

We Can Write Code using loop Like this.


Loop (Continue)

• A loop statement allows us to execute a statement or


group of statements multiple times and following is
the general for of a loop statement in most of the
programming languages

9/4/20XX Presentation Title 8


Loop
Steps
For loop Flow Chart

9/4/20XX Presentation Title 11


Nested Loop

• In Python, a nested loop is a loop inside another loop


Syntax:
Outer Loop:
Inner Loop:
Statements of inner loop
Statements of Outer loop
Note* indent is important
Flow Chart OF Nested Loop

9/4/20XX Presentation Title 13


While Loop

•A while loop repeats a block of code as long as a condition is True.

•It checks the condition first — if it's true, it runs the code inside.

•It stops when the condition becomes False.

9/4/20XX Presentation Title 14


Why use a while loop?

•When you don't know how many times you need to repeat.
•You want to keep doing something until a certain thing happens.

while condition:
# Code to repeat

9/4/20XX Presentation Title 15


Code

•i=1
• while i <= 5:
• print(i)
• i += 1

9/4/20XX Presentation Title 16


Flow Chart

9/4/20XX Presentation Title 17


Thank You 

9/4/20XX Presentation Title 18

You might also like