Watch on Instagram

Code Bytes · "Start Here: What Is Coding?" · Episode 1 · The big picture

What coding is

Coding is writing instructions a computer can follow, exactly as written and in order, like a recipe for a cook who takes every word literally. Three lines of Python, print("Boil water"), print("Add pasta") and print("Wait 10 minutes"), run top to bottom and print those three lines.

Posted · About a 1 minute watch, 3 minute read · Take the quiz

Instructions, like a recipe

A program is a set of instructions that tells a computer what to do. Writing those instructions is coding (or programming).

A good way to picture it is a recipe. A recipe is a list of steps: boil water, add pasta, wait 10 minutes. Now imagine the cook reading it takes every word literally. They don't fill in gaps, they don't fix mistakes, and they don't guess what you probably meant. That cook is the computer.

Computers can't guess

Computers are very fast, but they only do what the instructions say.

  • Skip a step, and the computer skips it too. If the recipe forgets "Add pasta", the cook boils water, waits 10 minutes, and serves you a pot of hot water.
  • Put steps in the wrong order, and the computer follows the wrong order.

So a big part of coding is being exact: every step written down, in the right order.

Your first real code

Here is real code in a language called Python:

``python print("Boil water") print("Add pasta") print("Wait 10 minutes") ``

  • print tells Python to show something on the screen.
  • The brackets ( ) hold what to print.
  • The quotes " " mark it as text, word for word. (That's why the screen shows 10 as a digit inside the quotes: it's just text to show.)

When you run it, the computer follows each line, top to bottom, exactly as written. The output is:

`` Boil water Add pasta Wait 10 minutes ``

From three lines to every app

Every app, game and website is built from instructions like these, just many more of them. A small program might be a few dozen lines; a big app can have hundreds of thousands or millions. The idea stays the same: exact instructions, followed one by one.

Try it yourself

Open any free online Python editor in your browser (search "online Python"), or type python3 on a computer that has Python. Paste this and press run:

``python print("Wake up") print("Brush teeth") print("Eat breakfast") ``

You should see the three lines printed in that order. Now swap the first two lines and run it again: the output changes order too, because the computer always follows your lines top to bottom. Then try deleting a quote mark and see what happens: Python stops and shows an error, because it can't guess what you meant.

Good to know

  • The code is Python 3. Every snippet on this page was run, and the outputs shown are copied from that run.
  • "Takes every word literally" and "in order" are a simplification: a program runs its lines top to bottom unless the code itself says to jump, repeat (loop) or choose between options. Those come later in Code Bytes.
  • "Millions" is loose: big apps have hundreds of thousands to millions of lines of code, and small ones far fewer.
  • In the video the voice says "ten" while the screen shows the digits 10 inside the quotes.

Answer to the comment question

print("Shoes") then print("Socks"): which word gets printed first? Shoes. Python runs the lines top to bottom, so it prints Shoes, then Socks. The computer doesn't know you'd normally put socks on first; it just follows the order you wrote. To get socks first, you'd have to swap the two lines.

Test your knowledge

Quick quiz: What coding is

4 multiple-choice questions. Pick one answer for each, then check how you did.

1What is coding?
2A recipe for a very literal cook leaves out "Add pasta". What happens?
3You run print("Boil water"), print("Add pasta"), print("Wait 10 minutes") on three lines. In what order do they run?
4In print("Add pasta"), what do the quote marks do?

Sources

Video transcript

What is coding, really?

Coding is writing instructions a computer can follow. Think of a recipe, written for a cook who takes every word literally.

Computers are fast, but they can't guess what you mean. Skip a step, and they skip it too. They just do what you wrote, in order.

Here's real code, in a language called Python. We type print, and in brackets, boil water, in quotes. Then add pasta, then wait ten minutes.

Press run, and the computer follows each line, top to bottom, exactly as written.

Every app, game and website is built from instructions like these. Just millions more of them.

Look at this code. Which word gets printed first? Comment your answer below!

That's your byte.

More from "Start Here: What Is Coding?"

All "Start Here: What Is Coding?" lessons