Skip to content
CCC Python Course

for loops and range

Stage
1
Module
M1.5
Lessons
1

In this module

  • Repeat a block of code a fixed number of times with for and range().
  • Choose the right form of range() to start counting from a value other than 0.
  • Build a running total across the passes of a loop with an accumulator variable.
  • Read a count, then that many more values, entirely inside a loop.

Before this module

Lessons

  1. 1for loops and range

Practice

Try these on the judges. Each link opens the problem on WMOJ or DMOJ.

  1. 2022 J2
    Fergusonball Ratings (opens on WMOJ in a new tab) WMOJ

    Rate each of several players from their points and fouls, and count how many earn a top rating.

  2. 2025 J2
    Donut Shop (opens on WMOJ in a new tab) WMOJ

    Track a donut count through a sequence of baking and selling events.

  3. 2016 J1
    Tournament Selection (opens on DMOJ in a new tab) DMOJ

    Count wins from a sequence of match results and report which group that count places a team in.

    Why DMOJ: Tries the same kind of counting on DMOJ, which holds 2014 to 2020.