Question:

What is looping, explain any one looping statement with suitable example?

Show Hint

For iterating over sequences like lists or numbers, use `for` loops. For conditions where the number of iterations is not known, use `while` loops.
Updated On: Jan 9, 2026
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Step 1: Understanding Looping.
Looping is a programming concept used to repeatedly execute a block of code multiple times based on a given condition. Loops are essential when you need to execute the same action multiple times, such as iterating through a list or running a repetitive task.
Step 2: Explanation of `for` loop.
A `for` loop is used to iterate over a sequence (like a list, tuple, string, or range) and execute a block of code for each element in the sequence. It is commonly used when the number of iterations is known beforehand.
Example of `for` loop:
Consider the following Python example:
for i in range(1, 6):
    print(i)
In this example, the `for` loop will iterate through the range of numbers from 1 to 5, and for each number, it will print the value of `i`. The `range(1, 6)` generates numbers starting from 1 up to, but not including, 6.
Step 3: Conclusion.
Looping allows you to execute the same code multiple times, and the `for` loop is commonly used when you need to iterate over a sequence of values.
Was this answer helpful?
0
0