Python Programming - Lesson 4 (Loops)

Words
167
Reading
1 min
Listen
Play
10y

In today's Python Lesson, we will be learning about Loops. Sequences are usually executed  sequentially, hence the name sequence. The statement is executed first followed by the second and it goes on. There may be a time where you need to run the same bit of code over and over again.

What does a Loop do?

A loop allows programmers to execute code or a group of statements multiple times. As you can, a loop would work like this:

Types of Loops

while loop - This loop repeats statements when the condition is set to TRUE. It tests the condition before executing to loop.

for loop - Executes statements multiple time and abbreviates code inside that loop.

nested loop - You can use multiple loops in another while statement. For example, the while loop.

Examples of loops:

While Loop:

For Loop:

Nested Loop:

Sorry for this being a short lesson. If you enjoyed please leave an UPVOTE and FOLLOW me for more content like this!

Thanks, Jack.

Python Programming - Lesson 4 (Loops) | Ecency