Game lab · Python Core

Robot Maze

Write Python to get the robot to the flag. Each level needs one new idea.

0 XP

Level 1: First steps

Calling a function

Move the robot four squares to the flag.

Press Run to send your program to the robot.

Robot commands

  • move() one square forward
  • turn_left() / turn_right() turn on the spot
  • front_is_clear() True if no wall ahead
  • at_goal() True when on the flag
robot.py
Output
Press Run to see the output. Python runs in your browser.
Need a hint?
Each move() goes one square forward. You need four of them.

Questions people ask

Is Robot Maze a good way to learn Python loops?

Yes. Each level is built so the obvious copy-paste answer stops working: level 3 rewards a for loop, level 4 changes length every run so only a while loop wins, and level 5 needs if/else inside a loop.

Is this real Python?

Yes. Your code runs in real CPython 3 in your browser (Pyodide). The only extra things are the robot commands: move(), turn_left(), turn_right(), front_is_clear() and at_goal().

What age is Robot Maze for?

Anyone who can read the instructions, from about age 10 up. Adults starting Python use it too, because seeing a robot hit a wall makes a logic bug obvious.

Learn the basics first in PY-101 Python Fundamentals →