← Course homeNext: Python lists →Code clears when you leave
MISSION 13 · PYTHON FUNCTIONS

Rover’s Reusable Route

Save a small movement recipe, then call it with different step counts. Predict first, inspect every real event, and explain how the parameter changes each trip.

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.

◇ Your mastery goalPython functions · Parcel helper

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

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

Parcel lane

0 / 3 checks

Rover carries a parcel along one straight lane, then uses the same helper for the second label count.

1
Read the current inputsThe values are visible. The challenge is reusing them in a meaningful helper.
first = 2second = 1Goal: 3 tiles ahead
2
Predict before RunDefining a function saves its body; it does not move the robot.
3
Write the reusable helperUse one definition, then call travel(first) and travel(second).

Allowed: def travel(steps):, for i in range(steps):, one move or turn in the body, and calls using first, second, or a number from 0 to 6.

Keep the function body indented. A zero argument is a real call whose loop body visits zero times. This is a small, bounded Python subset.

4
Robot map · inspected positionRover at column 1, row 2, facing E. Goal at column 4, row 2. Wall at column 5, row 2.
5
Function flowActual events from this run appear as you inspect them.

Function flow

✓ Inspected path ◆ Current step
Read or sketch a function

A definition saves a body; it does not move Rover. A call supplies a value for steps, runs the saved body, and returns to the next caller instruction. A zero argument still makes a call, but its range visits no values. The parameter belongs to this call; a later call supplies a fresh value.

On paper, draw the main route and the helper body in separate boxes. Draw a call arrow into the helper and a return arrow back. Count physical moves separately from calls. No photo or upload is needed. Tiny helper hats are optional.

Run an allowed program to draw its definition and calls.

Run a checked program to see its actual definition, calls, loop visits, and actions.

Help for this function puzzleHints build in steps. Worked help and solutions need a deliberate choice.

Highest help used on this case: 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. A chapter on functions covers def, parameters and return values.

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

    Free Harvard course with videos and notes. The first lecture shows how to define and call your own functions.

    • 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 lectures on functions.

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

    Step-by-step Python projects. Pick one and see how it splits work into small pieces. Some need hardware, so check the parts list.

    • Hands-on
    • May count visits