Loops in Python
Loops in Python
By,
Asst. Prof Mrs. Sneha Rose
IT Vertical
• Loops are important in Python or in any other programming language as they help you to execute a
block of code repeatedly.
• While all the ways provide similar basic functionality, their syntax and condition-checking time differ.
• In this class, we will look at Python loops and understand their working with the help of examples.
• Types of Loops
• For Loop
• While Loop
For Loop
• Keyword – for
• For loop is a control flow statement in programming that allows you to execute a
block of code repeatedly based on a specified condition.
• A for loop is used for iterating over a sequence (a list, a tuple, a dictionary, a set, or
a string).
• With the for loop we can execute a set of statements, once for each item in a list,
tuple, set etc.
Syntax in
C
Workflow
The range() Function
• To loop through a set of code a specified number of times, we can use
the range() function.