Programming is the art of making a computer play music, calculate maths problems, drawing the scenes from a game, building apps for your smartphone, desigining websites, or deciding when to turn on the water in a washing machine, yes, there's a tiny computer inside it too!

Like baking a cake

Programming a computer is just like writing the instructions for a recipe. The computer then follows these instructions. It does exactly what you tell it to do - so it's important that the instructions are written properly!

Att programmera en dator är precis som att skriva ett recept. Det är sedan datorn som följer dessa instruktioner. Den gör precis som du säger åt den - så det är viktigt att instruktionerna är skrivna rätt!

A famous programmer, or developer, Ted Nelson, said it like this:

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do."

We write these instructions in a language computers can understand. We call these programming languages. One of the more popular ones is Python and that's what we will be using here.

What is included in a computer?

Our brains can store memories, keep track of information, and think. In a computer, this is made possible by three different parts.

A computer often has a hard drive, which can store "memories" for a long period of time. We call these memories "files" and "folders".

A computer also has RAM - Random Access Memory, which is smaller but faster than a hard drive. Compare this to how we can hold just a few new digits in our head, maybe a phone number, but not very many.

And finally a computer also has a CPU (Central Processing Unit, or "processor"), which does the actual thinking. It is the CPU that receives instructions and performs tasks. This can be adding two numbers, drawing a red square on the screen, or sending a message over your online game.

When we program we write instructions, or code, in a file saved on the hard drive. When we start the program, it is moved over to RAM, and line by line the code is sent to the processor for execution. In that way, your computer bakes your cake according to your instructions!

Electronic computers in the form we know them today have existed since the 1950s, but at that time they were as big as a house. Today, computers are everywhere and they still operate in the same way, even if they are tiny by comparison.

What's so special about Python?

Just like with human languages there are many different programming languages. We can accomplish approximately the same thing in all of them, but they all have different "style", different "grammar", and are better suited for different purposes.

Python is often described as "easy to read" and it is not completely different from how we write mathematics.

Other popular languages include JavaScript, C#, Java och R.

We'll get started in the next section!

Read page in other languages

In this video, we're taking a closer look at the different parts of a computer, how they work, and where programming is used.

  • Programming language: A language used to create computer programs and apps. There are many, such as JavaScript, Python, and C++.
  • Hard drive: A hard drive saves information permanently, like the brain's long-term memory.
  • RAM: RAM is short for Random Access Memory. It contains the programs and apps that are currently running.
  • CPU: CPU is short for Central Processing Unit and is the very brain of the computer, it reads and carries out our instructions.