Coding for beginners: a robot and blocks
Snap a program together from blocks and watch a robot carry it out on a grid, step by step. Next to the blocks, the same program is written in Python. The levels take you through sequences, loops, conditions, while loops and functions.
New idea
A program is a list of instructions. The robot carries them out one after another, top to bottom, and does exactly what they say – it doesn’t guess. That’s why the order matters. Each block has its line of Python beside it: “move forward” is move(), “turn left” is turn_left().
In Python
move()
move()
turn_left()
move()Task
Take the robot to the flag. Tap “move forward” in the block menu: the block is added to the program. When the program is ready, press Run.
Hint
Count the squares between the robot and the flag. Each “move forward” takes the robot one square in the direction of the green arrow.
Map
Build a program and press Run.
Program from blocks
Block menu
Click a block to add it at the green line. You can also drag blocks with the mouse.
Keyboard: a new block goes after the selected one; move the selected block with Alt + arrow, delete it with the Delete key, Ctrl + Z undoes the last change.
The same program in Python
This is your program as text. Commands such as move() and turn_left() belong to this game; for, while, if and def are real Python.
Nothing here yet. Once you add blocks, their lines appear here.
A learning game; your program and progress stay in your browser. How it is calculated and where the data come from
What you will learn here
A program is an exact list of instructions. A computer doesn’t guess: it does precisely what the program says, even when that plainly makes no sense. So programming is mostly about breaking a task into small, unambiguous steps and putting them in the right order. That is the logic of programming, and it is the same in every language.
Sequence: commands run one after another, from top to bottom. Order matters: “move, turn left” takes the robot somewhere else than “turn left, move”.
Loops: instead of six identical “move” blocks, one “repeat 6 times” block with a single move inside is enough. In Python this is the loop for i in range(6):. Loops can go inside each other: four times round, “walk three steps and turn” goes around a square.
Conditions: an “if” block runs its blocks only when a condition holds, such as “if I am on a coin, pick it up”. An “if – else” block picks one of two ways. A program with conditions works even on a map you don’t know in advance, which is why these levels have several maps.
While loops: a “while” block repeats its blocks for as long as a condition holds, such as “while the path ahead is clear, move”. Unlike repeat N times, you don’t know in advance how many times it runs. If the condition never stops holding, you get an endless loop, one of the most common bugs there is.
Functions: a named piece of a program you can use again and again. Once you have built “turn around”, a single block calls it. The program gets shorter and easier to read, and a fix in one place applies everywhere.
Debugging: every programmer makes mistakes; the skill is finding them. Run the program step by step and watch where the robot does something other than you expected. The block that caused the error is highlighted, and the message tells you what happened.
Why blocks, and why Python beside them: with blocks you can’t make a typo or forget a bracket, so you focus on the logic alone. The Python beside them shows that it is the same program written as text: the blocks inside a loop are indented in the code, and the line above them ends with a colon.
Where to go next: once the robot stops surprising you, try writing Python yourself, for example with the official tutorial at python.org, which starts with the same for, while, if and def. If you would rather make games and animations, carry on with Scratch, which uses the same kind of blocks.
Frequently asked questions
What age can kids start coding?
This game is written for about ten and up, and it suits adult beginners too. Younger children can manage the first chapters with an adult’s help; being able to read is enough. All levels are unlocked, so anyone who knows the basics can skip ahead.
Is it free, and do I need an account?
It is free, with no sign-up. Your browser remembers your progress, so you can come back to a level on the same device.
What is Python?
Python is one of the most widely used programming languages. It is used for data analysis, science, websites, automation and artificial intelligence, and beginners like it because it reads easily. The program beside the blocks is real Python; only the robot’s commands, such as move(), belong to this game.
How is this different from Scratch?
Scratch is an open playground where you build your own games and animations with characters from blocks. Here you solve puzzles with a clear goal that take you step by step through ideas such as loops, conditions and functions, and you see the same program in Python beside the blocks. The two go well together.
What next, once I have finished all the levels?
Try writing Python yourself: the official tutorial at python.org starts with the same if, for, while and def you know from the blocks. If you enjoy making things more, carry on with Scratch. And try solving the levels with fewer blocks.
Is my program sent anywhere?
No. The program runs in your browser and is saved only in its storage, so you find it next time. It is not sent anywhere and nobody else sees it.
How it is calculated and where the data come from
How the result is calculated
- A program is made of blocks. Each block matches one or more lines of Python generated beside it, so while the program runs, the block and its line light up together.
- The robot lives on a grid of at most 8 × 8 squares. A square is free, a wall, a coin or the goal with a flag; the edge of the grid is a wall. The robot stands on one square and faces one of four directions.
- When you press Run, the whole run is worked out in advance and then played back. Every command carried out is a step, and so is every condition checked (“Is the path ahead clear? Yes”). The same program on the same map always runs the same way.
- A level is solved when the program finishes without an error, the robot ends on the goal (if the map has one) and no coin is left. Some levels have two or three maps and the program must pass them all: the map on screen runs visibly, the others are checked quietly, and if one of them fails, the game switches to it and shows why.
- A run stops with an error at the block that caused it: the robot would hit a wall, it would pick up a coin where there is none, or the program is empty. After 1,000 steps a run stops as an endless loop, and a function that calls itself more than 50 levels deep stops as endless calling.
- Some levels allow only a limited number of blocks. Every block counts, including the blocks inside loops, conditions and functions; a block that holds other blocks counts once.
- The program you are working on in each level and the list of solved levels are stored only in your browser’s storage.
Assumptions and limits
- The robot knows only 4 commands (move forward, turn left, turn right, pick up a coin) and 5 conditions (path clear ahead, on the left and on the right, standing on a coin, at the goal), each of them also negated.
- There are no variables, no arithmetic with numbers and no functions of your own with parameters. The level sets up each function (its name and purpose); you build only what it does.
- The Python is read-only: it shows what the program looks like as text, but you can’t type it yet. Commands such as move() or path_ahead() are functions of this game, not part of Python, so the code on its own won’t run outside the game.
- The names in Python are in English (move, turn_left, pick_coin…), as in real programs; the blocks are in the language of the page.
- The robot does exactly what the program says; it doesn’t guess or fix anything. That is not a shortcoming: it is the main thing to learn here.
We designed the maps and levels ourselves as exercises; they are not data. The idea of a robot led through a grid by a program comes from Karel the Robot, which Richard E. Pattis described in 1981 as a first lesson in programming.
Data sources and the period they hold for
Every number a calculator starts with or computes from comes from one of the sources below. Series names are given as the publisher names them. Each row shows the period the data refer to and, where we record it, the day we downloaded them. Official data can be months old when they are published, so check the current figure before you decide.
- Official
- Published by a central bank, a statistical office, the European Union or another public body.
- Research or industry data
- A dataset of a university, an index provider, an industry association or a data vendor.
- Reported
- A figure of an official body that we know only from the press and did not check in the primary source. Treat it as approximate.
- Example
- A round number of ours, not a statistic. Replace it with your own.
Programming basics and the Python language
| Source | Period | Type |
|---|---|---|
Python Software FoundationThe Python Tutorial, 4. More Control Flow Tools (if, for, range, def) | currentdownloaded 2026-10-19 | Research or industry data |
Python Software FoundationThe Python Language Reference, 8. Compound statements (if, while, for, function definitions) | currentdownloaded 2026-10-19 | Research or industry data |
Richard E. PattisKarel the Robot: A Gentle Introduction to the Art of Programming (John Wiley & Sons, 106 pages) | 1981downloaded 2026-10-19 | Research or industry data |
Methodology text last reviewed 2026-10-06. Data last downloaded 2026-10-19. How we work with data and sources