← Course homeCode clears when you leave
MISSION 08 · PYTHON LOOPS

How Many Times Around?

Repeat a short group of robot actions. Predict where Rover ends, inspect every loop visit, and explain how the body is counted.

What’s saved: your code, predictions and answers clear when you leave this page or reload. If you turn saving on, only which puzzles you finished and how much help you used is kept on this device. Test accounts also share it, and lesson timing, with the site’s maintainer.

Next: M09 · Stop Means Stop →

◇ Your mastery goalPython counted loops

Complete all 4 required tasks with a correct prediction, an inspected trace and an explanation that shows the concept. At least 3 must be independent checks, without answer-level help.

✓ Qualifying tasks: 0 / 4◎ Independent checks: 0 / 3 required
PRACTICE · 1 OF 4

Sock conveyor

0 / 4 checks

Rover is sorting socks on a short conveyor. Send the parcel east to the star with one useful counted loop.

Loop rule: A qualifying program consists of one for loop with a count of at least 2 and an action-only body that includes a move. Actions outside the loop are allowed for experiments, but those programs do not qualify for this puzzle.

1
Predict before RunUse one-based column and row labels. Count only successful moves; turns do not add moves.
2
Write the counted loopIndent each action so it belongs to the loop body.

Allowed: for i in range(0): through range(8), move(), turn_left(), turn_right(), comments and blank lines.

Use a literal count from 0 to 8 and a nonempty, action-only indented body. The puzzle requires one loop with count at least 2. For a nonempty range, Python i starts at zero. A zero count visits no values; reading i in code is outside this lesson.

Allowed Python syntax

One top-level for i in range(number):, followed by one or more indented robot actions. Counts are whole numbers from 0 to 8. Comments, blank lines and action calls outside the loop are allowed for experiments, but outside actions do not qualify for this puzzle. No nested loops, conditions, assignments, reading i, pass, else, or other code.

FLOWCHART · INSPECTED PATH

Run an allowed program to check its syntax and reveal the flowchart. Predict first; then inspect every visit.

PLAN VIEW

Flowchart

Bounded plan · up to 64 blocks
✓ Inspected path ◆ Current step
How to read this chart

Follow the arrows from Start. Rectangles show actions. A diamond asks a question: follow the labelled TRUE or FALSE path. Only the matching path runs; both paths merge before the next step. Stacked branches are alternatives, not consecutive steps.

A Repeat uses a counter: set i = 0, check i < count, run the whole body, add one, and return to the check. Repeat 5 means five body visits; repeat 0 skips the body. The Python spelling for i in range(5): visits counter values 0, 1, 2, 3, 4: five visits. The trace numbers those visits 1–5. The Python loops workshop supports this bounded for/range form; other workshops keep their own allowed syntax.

Counter setup, increment and exit arrows explain the loop; they are conceptual, not extra recorded trace events. Highlighting follows actual actions, decisions and beginning-of-iteration markers. End is highlighted only after an inspected run finishes normally. For Python, the diagram’s counter setup and increment explain repetition; they are not executed assignments. A zero-count range visits no values and does not assign a new value to Python i.

Design on screen or sketch on paper

Edit the short program in the Python editor. Run checks its syntax before drawing the chart; your prediction stays frozen for that run. Worked examples show separate authored programs.

  1. Draw a rounded Start. Connect each step with an arrow.
  2. Put each action in a rectangle, in the order it happens.
  3. For IF, draw a diamond with a yes/no question. Label both TRUE and FALSE arrows, write each branch, then merge them.
  4. For a loop, mark the repeat count and draw its whole body. Show a counter starting at 0, a counter-less-than-count question, and a YES arrow into the body.
  5. After the body, add 1 to the counter and draw an arrow back to its question. The NO arrow leaves the loop. A count of 0 goes straight to NO.
  6. Finish with a rounded End. Trace with a finger or pencil; note position, heading and any changing values after each action.

Keep your paper sketch beside you; no photo or upload is needed. Robot doodles are optional. Magnificent robot hats are also optional.

Start or End Action Decision Order

Run an allowed program to see its actions and decisions here.

  1. Start
  2. End

MAP · FULL ROUTE

Predict Rover’s route

1, 5 · E

Start: column 1, row 5, facing E. Rover now: column 1, row 5, facing E. Goal: column 4, row 5. No walls.

↑ Rover★ Goal
4
Explain the loopWhat does the range count control in this loop? One explanation per completed, fully inspected run.
Choose an explanation
Help for this loop puzzleHints build in steps. Worked help requires a deliberate choice.

Highest help used on this case in this session: none

For Further Reading and Exploration

These are outside sites with their own rules. You will see a notice before you leave. Pick one, not all.

  • Automate the Boring Stuff with Python

    Free book to read online. The flow control chapter covers for loops and range() with short examples to try.

    • Hands-on
    • May need an install
    • Ask an adult
  • CS50's Introduction to Programming with Python

    Free Harvard course with videos and notes. A lecture on loops covers for loops and lists, with practice problems.

    • Hands-on
    • Advanced
    • May count visits
  • MIT OpenCourseWare 6.100L

    Free college course notes and videos. It moves fast, so take one topic at a time. Look for the lecture on iteration, which covers loops.

    • Hands-on
    • Advanced
    • May count visits
  • Raspberry Pi Foundation Projects

    Step-by-step Python projects. Pick one that repeats something and change how many times. Some need hardware.

    • Hands-on
    • May count visits