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
- The robot starts facing along the conveyor. Your commands:
move(),turn_left(),collect(), plus a sensor or two on later levels. - Write the program in the editor and run it — Auto mode runs each line as you finish it.
- Collect the gears (and skip the scrap), then finish on the glowing exit pad.
- Short programs earn three stars; the spiral level is random, so hard-coded routes fail.
All 6 levels — what each one teaches
| # | Level | Python idea | Goal |
|---|---|---|---|
| 1 | Power On | Calling functions | Pick up the gear, then park on the exit pad. |
| 2 | Patrol Loop | for loops | Drive round the machine, collect 3 gears and end on the exit pad. |
| 3 | Rush Order | Variables | Collect exactly order() gears, then reach the exit. |
| 4 | Right Turn Only | Functions | Write turn_right() and go down the stairs collecting every gear. |
| 5 | Quality Control | if statements | Collect every gear, skip all the scrap. |
| 6 | The Spiral Corridor | while loops | Follow 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.
More Python adventure games
- Python adventure game — Python Quest
- Python space shooter game — Code Defender
- Python turtle online — Python Painter
- Python farming game — Python Farmer
- Python treasure hunt game — Treasure Hunter
- Python math game — Math Island
- Python rocket game — Space Explorer
- Python strategy game — Castle Builder
- Python string game — Word Locks
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