Chapter 6

Programming Basics

Meet the building blocks of coding: instructions, sequence, selection and loops.

What is programming?

Programming means giving a computer a list of instructions to follow. Each instruction is a small step. The computer follows the steps exactly and in order, so the instructions must be clear and correct.

Key idea

Three basic building blocks of a program are sequence (steps in order), selection (make a choice) and loop (repeat steps).

The three building blocks

  • Sequence: the computer does the steps one after another, in order.
  • Selection: the program chooses what to do, using if a condition is true.
  • Loop: the program repeats steps instead of writing them many times.

A flowchart is a diagram that shows the steps of a program using boxes and arrows. It helps you plan before you code. A variable is like a labelled box that stores a value, such as a score, that can change while the program runs.

Example

A loop tells the robot: repeat 4 times: move forward, then turn right. This draws a square without writing the two steps four times.

Planning first

Good coders plan first, then write the instructions, then test the program. If there is a mistake, called a bug, they fix it and test again.

Stuck on this topic? A verified JomKelas tutor can walk you through it.

Find a verified tutor