Loops make it possible to define cycles in the execution flow of an algorithm.
# Initialize a few variables
v : List[int] = [1, 5, -5, 15, 0]
maxv : int = v[O] if len(v) > 0 else None
i : int = 0
# A loop that will iterate n times
for i in range(len(v)):
if v[i] > max:
max = v[i]
An invariant is used to prove by induction that a loop effectively reaches an expected state from an initial state.