Coding Python
Home›Python Coding Games›Robot Factory

Karel Python Online: Robot Factory

A Karel-style robot that only knows how to move, turn left and pick things up. Everything else, you teach it in Python.

About this karel python

Karel the Robot has taught programming at Stanford and in countless classrooms for one reason: a robot with three commands forces you to build everything else yourself. Robot Factory keeps that idea and puts it on a factory floor in Python. The famous moment is level four — the robot cannot turn right, so you write def turn_right(): from three left turns — and the last level is a spiral corridor that changes every run, so only a real while loop with front_is_clear() gets through.

How to play Robot Factory

  1. The robot starts facing along the conveyor. Your commands: move(), turn_left(), collect(), plus a sensor or two on later levels.
  2. Write the program in the editor and run it — Auto mode runs each line as you finish it.
  3. Collect the gears (and skip the scrap), then finish on the glowing exit pad.
  4. Short programs earn three stars; the spiral level is random, so hard-coded routes fail.

All 6 levels — what each one teaches

#LevelPython ideaGoal
1Power OnCalling functionsPick up the gear, then park on the exit pad.
2Patrol Loopfor loopsDrive round the machine, collect 3 gears and end on the exit pad.
3Rush OrderVariablesCollect exactly order() gears, then reach the exit.
4Right Turn OnlyFunctionsWrite turn_right() and go down the stairs collecting every gear.
5Quality Controlif statementsCollect every gear, skip all the scrap.
6The Spiral Corridorwhile loopsFollow a random corridor to the exit, collecting every gear.

New to these ideas? Each level pairs with a free lesson: loops, variables, functions and conditions. When you finish, try Python Farmer next.

Prefer to code on your phone? Keep practising on Android: the free Coding Python app is a full Python 3 editor and interpreter with 30 examples and 12 challenges.
Get the free app

More Python adventure games

Or browse all the Python coding games.

Frequently asked questions

Is this the same as Stanford's Karel?

It follows the same idea — a robot with a tiny command set you extend with your own functions — but it is its own game, written for Python 3 and played in the browser with no install.

How is Robot Factory different from Robot Maze?

Python Robot Maze is about route-finding through floating walkways. Robot Factory is the Karel-style one: turning only left, writing turn_right(), and using sensors like front_is_clear().

Is it free, and do I need to sign up?

It is free with no account. The game runs in your browser and saves your progress in this browser only.

Does it run real Python?

Yes. Your code runs on CPython compiled to WebAssembly (Pyodide) inside the page. Errors are real Python errors, and an endless loop is stopped after a few seconds instead of freezing the tab.

Does it work on a phone?

Yes. On narrow screens the editor sits at the bottom of the game. For longer coding sessions on Android, the free Coding Python app has a full Python editor.

Take Python with you

Coding Python packs a real Python 3 compiler, 30 example programs, 112 quiz questions and 12 self-checking challenges into one free Android app.

Get it on Google Play
Coding Python app icon