Programming Basics: Instructions, Sequence and Bugs
What Is a Program?
A program is a set of precise instructions that a computer follows exactly. A computer cannot guess what you meant. It does only what it is told, in the order it is told.
Sequence
Sequence means the instructions happen one after another, in order.
A program to move a robot:
move forward 2
turn right
move forward 1
If the robot starts facing north, it moves 2 steps north, turns right to face east, then moves 1 step east.
Order Matters
Putting the instructions in a different order gives a different result. Making a sandwich only works if you spread the butter before putting on the top slice of bread.
Predicting
Before you run a program, predict what will happen by reading each instruction carefully, in order. This is logical reasoning.
Program: move 3 steps, then move 2 steps. Prediction: the robot moves 5 steps in total.
Bugs and Debugging
A bug is a mistake in a program. Debugging means finding and fixing it.
- Run the program and watch what happens.
- Find where it goes wrong.
- Fix the instruction.
- Test again.
Programming Tools
Young programmers often start with a floor robot (such as a Bee-Bot) or block-based tools such as Scratch, where you snap coloured blocks together.
Break It Down
Big problems are easier when you split them into smaller steps. Programmers call this decomposition.
Curriculum link: National Curriculum in England: Computing programmes of study (DfE) — Key Stage 1: create and debug simple programs; use logical reasoning to predict the behaviour of simple programs