Module 1

Programming Basics

Before we write any code, let’s understand what programming actually is and how computers think.

1. What is a program?

A program is a set of instructions that tells a computer what to do. Computers are fast but not clever. They only do exactly what we tell them.

Think about making a cup of tea. You know to boil the kettle before pouring water into the cup. A computer needs that same order of steps written down.

Key idea: Programming is just clear instructions in the right order.

2. Algorithms

An algorithm is a step-by-step plan for solving a problem. It doesn’t have to be in code. A recipe is an algorithm!

Algorithm for making toast:

  1. Take a slice of bread.
  2. Put it in the toaster.
  3. Push the lever down.
  4. Wait until it pops up.
  5. Add butter.

You try

Write an algorithm with 5–7 steps for brushing your teeth. Swap with a partner. Did you miss any steps they thought were obvious?

3. Variables

A variable is a named box that stores a piece of information so we can use it later. Picture a labelled drawer.

# Variables in Python
name = "Ava"
age = 13
score = 0

The name on the left is the label; the value on the right is what’s in the drawer. You can change what’s in the drawer at any time.

TypeHoldsExample
Stringtext"hello"
Integerwhole number42
Floatdecimal number3.14
Booleantrue or falseTrue

4. Decisions (if / else)

Programs make decisions using if statements. The computer checks a condition, then chooses what to do.

if score >= 10:
    print("Well done!")
else:
    print("Keep trying.")

Read it in English: “If the score is at least 10, say ‘Well done!’. Otherwise, say ‘Keep trying.’”

5. Loops

A loop repeats a block of code. Instead of writing the same thing 10 times, we tell the computer to repeat.

for i in range(5):
    print("Hello!")

This prints “Hello!” five times. Loops are what make games, animations and data processing possible.

6. Bugs & debugging

A bug is a mistake in your code. Debugging is the skill of finding and fixing bugs. Every programmer (even experts) writes bugs. That’s normal.

  • Read the error message carefully; it usually points to the line.
  • Check your spelling and capital letters.
  • Try the smallest possible version of your code to isolate the problem.
  • Explain the code out loud to a classmate (or a rubber duck!).

Glossary

Algorithm
A step-by-step plan to solve a problem.
Variable
A named store for data.
Condition
An expression that is either true or false.
Loop
A block of code that repeats.
Bug
A mistake in a program.
Syntax
The grammar rules of a programming language.