For absolute beginners

Introduction to Programming

No programming language required. First you learn to think like a programmer, giving the robot commands and learning algorithms live. Then you choose the path that suits you.

Get started
8 modulesRobot-executorCertificate
LIVE DEMO

Which command gets the robot to the star?

Correct! The robot made it.
MODULE 1

What a program is and how it works

1

How a computer "thinks"

A computer is very fast, but it does not think on its own. It only carries out the command you give, in the order you give it, exactly. It adds nothing, and leaves nothing out.

That is why a programmer's main job is to give the machine precise, step-by-step commands. If you say "take the apple", it won't understand. You have to spell out every step: "move forward, move forward, take the apple".

The robot below works just like a computer. Its program (the list of commands) is on the left, and it runs on the right. Each command lights up and runs in turn:

Key idea: a program is a precise sequence of commands given to a machine.
2

Algorithm = a sequence of steps

An algorithm is a precise sequence of steps for getting something done. You use them every day: brewing tea is an algorithm too. What matters is the order of the steps. Break the order and you break the result.

The robot needs the same thing: steps in the right order. In the next lesson you will write an algorithm for the robot yourself.
3

Your first program

Now it's your turn. Guide the robot all the way to the apple. Click the commands below to build a program, then press Run. The robot runs your program top to bottom, exactly.

Tip: watch which way the robot is facing. Use the "turn" commands to change its direction.

Here is how this looks in real code
The program you gave the robot
How a real programmer writes it
See it? Real code is exactly the same: a list of commands written in order. Just in text form.

Module test

Answer at least 3 of the 4 questions correctly to unlock the next module.

Module 2 is lockedFinish Module 1 (all three lessons + the test) and this module unlocks.
MODULE 2

Algorithms and flowcharts

1

Breaking a problem into steps

The secret to solving any big task is to break it into small, precise steps. Getting a robot out of a maze, or building a website, both start by splitting the work into stages.

Programmers often draw these steps as a flowchart: each action is a box, arrows show the order, and a diamond represents a condition (yes or no). The flowchart below shows how the steps run one after another:

A flowchart is a way to plan an algorithm visually before writing any code.
2

Planning ahead for the robot

Now a bigger maze. To get the robot to the apple, plan ahead: where to go straight, where to turn? Think through each turn in advance, that is what planning an algorithm means.

Here is how this looks in real code
The program you gave the robot
How a real programmer writes it
The principle is the same in a long program too: break the problem into steps and carry them out in order.

Module test

Answer at least 3 of the 4 questions correctly to unlock the next module.

Module 3 is lockedFinish Module 2 to unlock this module.
MODULE 3

Variables

1

Storing a value: the box

A variable is a named box where a value is stored. You can put a number, text, or a yes/no (boolean) value in it, and change it as often as you like.

Try the "score" box below. When you click the buttons, the value inside changes, but the name of the box stays the same:

In a program, score = score + 1 means: take the current value of the score box, add 1, and put it back in the same box.
2

The robot counts apples

Now the robot collects several apples. Each time it picks one up, the apple variable goes up by 1, just like a counter. Teach the robot to collect all three apples and watch the counter:

Here is how this looks in real code
The program you gave the robot
Each "take the apple" increases apple
Variables give a program memory: it can count something, remember it, and use it later.

Module test

Answer at least 3 of the 4 questions correctly to complete the module.

Module 4 is lockedFinish Module 3 to unlock this module.
MODULE 4

Conditions (if...)

1

The robot makes a decision

So far the robot has followed commands blindly. But real programs can look and make decisions: "if something is true, do this; otherwise, do something else". This is called a condition.

An everyday example is a traffic light: "if the light is red, stop; if it's green, go". The robot also "sees" what's ahead and picks its path accordingly. Below, two cases light up in turn:

A condition gives the robot a choice: one action in one case, another action in another.
2

Controlling with a condition

Now the robot can land in two different situations, but it doesn't know in advance which one. Build a single program that works in both situations. The trick: use the "if there's a wall ahead, turn right" condition.

Use the "Situation A / B" button above to switch between the cases. One program (without changing it) must solve both.

Here is how this looks in real code
The program you gave the robot
"if" is the keyword
One program, two cases. Thanks to the condition, the robot adapted to the situation. In real code this is called if.

Module test

Answer at least 3 of the 4 questions correctly to unlock the next module.

Module 5 is lockedFinish Module 4 to unlock this module.
MODULE 5

Repetition (loops)

1

Doing one thing many times

Sometimes you need to write the same command over and over. A loop (repetition) shortens this: "repeat 6 times: forward" means run "forward" 6 times.

Below, the two give the same result, but the loop is much shorter:

Without a loop (6 commands)
forward forward forward forward forward forward
=
With a loop (1 block)
repeat 6 times: forward

The robot below moves using a loop. The loop counter goes up with each repetition (for example 1/5, 2/5 ...):

A loop is the secret to short code: write little, do a lot.
2

Controlling with a loop

Guide the robot to the apple, but the path is long. Instead of writing "forward" many times, use a loop: click the "repeat" button and adjust the number with − / +.

Here is how this looks in real code
The program you gave the robot
A loop in real code: for
In real code a loop is called for or while. The idea is the same: repeat a block a set number of times.

Module test

Answer at least 3 of the 4 questions correctly to complete the module.

Module 6 is lockedFinish Module 5 to unlock this module.
MODULE 6

Functions

1

Giving commands a name

Sometimes you use a group of commands over and over. If you bundle them under a single name, you get a function. After that you just "call" the name and the whole group runs.

An everyday example: say "brew tea" and every step happens on its own. Below, the stairs() function gives a name to the motion of climbing one "step":

Function definition
stairs() = forward → turn left → forward → turn right

The robot below climbs the steps by calling stairs(). When it's called, the function block lights up:

A function gives a name to a group of commands: write it once, call it many times.
2

Controlling with a function

The robot needs to climb a staircase. Every step is the same motion, that is stairs(). Instead of rewriting four commands each time, call the function. Click the "stairs()" button a few times and take the apple.

Function definition
stairs() = forward → turn left → forward → turn right
Here is how this looks in real code
The program you gave the robot
Function: defined once with def
In real code a function is defined once with def, then called by its name as many times as you like.

Module test

Answer at least 3 of the 4 questions correctly to complete the module.

Module 7 is lockedFinish Module 6 to unlock this module.
MODULE 7

Errors and debugging

1

What an error is and how to find it

Every programmer makes mistakes, and that's normal. When a program stops working or gives a wrong result, there is an error (in English, a "bug") in it. The process of finding and fixing an error is called debugging.

If the robot doesn't reach the apple or bumps into an obstacle, it means there is an error in the program. A good programmer doesn't panic, but finds the error with the following steps:

A key tool is the "Step" button: run the program one command at a time and see EXACTLY which command the robot gets wrong.
2

Find and fix the error

The program below has an error: the robot hits an obstacle instead of reaching the apple. First use "Run" to see where it stops, and check with "Step" if needed. The error is one extra "forward" in the first row. Click the extra command to delete it and run again.

Here is how the fixed code looks
The program you fixed
In real code
The method is the same in big programs too: isolate the error, observe, fix, and test again.

Module test

Answer at least 3 of the 4 questions correctly to complete the module.

10-STAGE CHALLENGE

It gets harder stage by stage

10 mazes, each harder than the last. Solve each stage to unlock the next. Here you use all the commands you have learned.

FREE MODE

Build your own maze

No grades here, no limits. First, in Build maze mode, click the cells to place walls, apples and the robot's position. Then switch to Programming mode, control the robot with all the commands you have learned, and solve the field.

Certificate is lockedFinish all 7 modules and the 10-stage challenge to unlock your certificate.
CERTIFICATE

For completing the full course

Enter your name, view your personal certificate confirming that you finished the "Introduction to Programming" course, including the 10-stage challenge, and download it as an image.