Fish 1 Fish 2 Fish 3 Fish 4

Lesson 2: Introduction to Loops

In this lesson, you’ll learn how loops allow you to repeat actions in your program multiple times. Loops are an essential tool in programming.

What is a Loop?

A loop is a programming structure that repeats a block of code a certain number of times or until a condition is met. Below is an example of a simple loop:

Example in Python:

for i in range(5):
    print("This is loop iteration", i)
            

Your Task:

Try running the loop above in Python to see how it works. The loop will print the statement multiple times.

Watch the Video:

Quiz: Test Your Knowledge!

What will the following Python code output?

for i in range(3): print(i)
Select an answer to check if you're correct!

© 2025 Ocean Explorer | All Rights Reserved