> ## Documentation Index
> Fetch the complete documentation index at: https://python-training.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Module 5: Loops

> Repeat work with while and for, generate sequences with range(), nest loops, and steer them with break, continue, and pass.

| | |
| - | - |
| **Exam** | PCEP-30-03 |
| **Section** | 2. Control Flow: Conditional Blocks and Loops (23% of the exam) |
| **Objectives** | 2.2.1, 2.2.2, 2.2.3, 2.2.4, and 2.2.5 |
| **Exam questions** | About 5, one per objective |

By the end of this module you can do everything below. The objectives and their wording come from the [official PCEP-30-03 syllabus](https://pythoninstitute.org/pcep-exam-syllabus).

## 2.2.1 Create condition-controlled loops using `while`

* Use a `while` loop to repeat instructions while a condition remains true.
* Initialize and update loop-control variables (sentinel values).
* Trace the execution of a condition-controlled loop.
* Recognize conditions that may result in an infinite loop.
* Use assignment expressions with the walrus operator `:=` where appropriate.

## 2.2.2 Iterate through sequences and iterable objects using `for` and `in`

* Use a `for` loop to iterate through a sequence or iterable object.
* Use the `in` operator to retrieve successive elements from an iterable.
* Iterate through common iterable objects such as strings, lists, and tuples.
* Process each element of an iterable within a loop.
* Trace the values assigned to the loop variable during execution.

## 2.2.3 Generate numeric iterations using `range()`

* Use `range()` to generate integer sequences for loop iteration.
* Use the start, stop, and step arguments of `range()`.
* Use positive and negative step values.
* Trace the values produced by `range()` during loop execution.

## 2.2.4 Construct nested loops and combined control structures

* Nest one loop inside another loop.
* Combine loops with conditional statements.
* Trace the execution order of nested loops.
* Use nested loops to process multidimensional or grouped data.

## 2.2.5 Control loop execution using `break`, `continue`, and `pass`

* Use `break` to terminate a loop before its normal completion.
* Use `continue` to skip the remainder of the current iteration.
* Use `pass` as a syntactic placeholder for an empty block.
* Trace loops that contain `break`, `continue`, or `pass`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.