Text 1 - What is a loop?
A loop in programming is a control flow statement that allows code to be executed repeatedly based on a condition. The basic idea is to have a block of code that runs multiple times, depending on whether a condition is true or false. There are several types of loops, each suited to different scenarios:
1. For Loop: Typically used when the number of iterations is known beforehand. It iterates over a sequence (like a list, tuple, or range).
Example in Python:

This will print numbers from 0 to 4.
2. While Loop: Runs as long as a condition is true. It's useful when the number of iterations isn't known in advance and depends on some condition within the loop.
Example in Python:

This will also print numbers from 0 to 4.
3. Do-While Loop: Similar to a while loop, but the condition is checked after the loop body has been executed, ensuring that the loop runs at least once. Note that Python does not have a built-in do-while loop, but it can be simulated using a while loop.
Example in other languages (like JavaScript):

This will print numbers from 0 to 4.
4. Foreach Loop: Specifically used for iterating over elements in a collection or array. It's common in many programming languages to simplify looping over elements.
Example in Python:

This will print each fruit in the list.
Loops are fundamental constructs in programming, allowing for efficient and compact execution of repetitive tasks.