Facts

Grown-ups

Facts the Peabody Encyclopedia for kids

What grade are you in?

Real facts about everything, written for your grade.

What grade are you in?

Variables, Loops and Bugs

How Coding Works: How do people write code?

Read it with Peabody

How do people write code? Let us start with one fact, and then build from there. You may have heard that a computer can think for itself. In fact, it cannot. People have to give it instructions. A program is a list of instructions. People called programmers write the code that makes programs. Code is the special language a computer understands.

Look at what is made this way. Games, websites and animation tools are all made with programs. Now think about the steps in a list of instructions. They have to be in the right order. A computer follows its commands one after another. It does them in the order it is given them. The order of the instructions in a program is called its sequence.

Here is a big word. An algorithm is a list of steps for solving a problem or getting something done. A recipe is an algorithm for people. Now think about a big job. It can be hard to do all at once. Decomposition means breaking a big problem into smaller parts. That makes it easier to tackle.

Next, think about a job that has to be done many times. A loop makes a computer repeat a set of instructions. A loop can repeat a set number of times. It can also repeat until something happens. A loop lets code do the same kind of job many times. It does not have to be written out again each time.

Next, think about remembering things. A variable is like a box that holds a value. The value inside can change. Every variable gets its own name. The name lets the program find what is stored in it. A program can use a variable to keep track of something that changes, like a score or a count of clicks.

Now think about making a choice. A program can make a choice with commands like IF, THEN and ELSE. A conditional runs one set of code if a test is true. It runs another set if the test is not true. Think of taking an umbrella only if it is raining. The rain is the test.

Here is a new word: function. A function is a named piece of code. It can be run, or called, whenever it is needed. Think about the word named. The piece has a name. Here is a question: what is a function? It is a named piece of code that can be run whenever it is needed.

Here is one more idea: a list. A list in a program holds many items under one name. Think about the words many items and one name. A list can hold a lot of things. All of the items sit under one name. Here is a question: what is a list? It holds many items under one name.

A mistake in a program is called a bug. You may have heard that a bug is a real insect inside the computer. In fact, a bug is a mistake. There are syntax bugs, which are typing mistakes in the code. There are also logic bugs. Programmers can find a bug by checking a program one small step at a time. Debugging means finding and fixing the bugs.

Here is a question: do you need a computer to learn about coding? You may have heard that you can only learn about coding on a computer. In fact, unplugged coding activities use games, cards and puzzles instead of a computer. As of November 2026, Scratch is a coding tool where kids make their own stories, games and animations.

Words to know

  • algorithm: list of steps
  • loop: a repeat
  • variable: changing box
  • conditional: if test
  • function: named code
  • debugging: fixing mistakes

The short version

A computer program is a list of instructions for a computer. A computer cannot think for itself, so people have to give it instructions. People called programmers write the code that makes programs. Code is the special language that programs are written in, and a computer understands it.

Quick facts

  • A computer program is a list of instructions for a computer.
  • A computer cannot think for itself, so people have to give it instructions.
  • A loop makes a computer repeat a set of instructions.
  • A variable is like a box that holds a value, and the value inside can change.
  • Debugging means finding and fixing the bugs in a program.

How do people write code?

People called programmers write the code that makes computer programs. Code is the special language that programs are written in, and a computer understands it. A program is a list of instructions, and the steps in it have to be in the right order.

What is a bug in coding?

A mistake in a computer program is called a bug. There are syntax bugs, which are typing mistakes in the code, and logic bugs. Debugging means finding and fixing the bugs in a program, and programmers can find a bug by checking a program one small step at a time.

Read next

Sources

For grown-ups: Peabody has no ads, not one, and nothing to sell your child. The Kids Pick, an independent kids' directory, rates its games 90/100. See what other free kids' sites load Β· Grown-ups, sign in Β· Already have a profile?