Chapter 4: Problem 3
What is a count-controlled loop?
Short Answer
Expert verified
Answer: A count-controlled loop is a programming concept used to execute a block of code a specific number of times, determined by a counter variable. It is useful when you know how many times you want to execute a specific piece of code. In Python, a count-controlled loop can be implemented using the "for" loop. For example:
```python
# We want to print numbers from 1 to 5
for i in range(1, 6):
print(i)
```
In this example, the "for" loop iterates through a sequence of numbers from 1 to 5, printing each number, and terminates when there are no more numbers left in the sequence.