Programming Basics – SS2 Digital Technologies Lesson Note (Second Term)
Download this term · ₦1,000Lesson note at a glance
- Subject
- Digital Technologies
- Class
- SS2
- Term
- Second Term
- Topic
- Programming Basics
- Order
- Topic 3 of 8 this term
- Reading time
- 5 min
A computer program is a list of instructions that tells a computer what to do.
- Variables: memory locations that store data.
- Data types: tell the computer whether data is a number, text or a logic value.
- Operators: symbols that add, compare or assign data.
Behavioural objectives
By the end of the lesson, students should be able to:
- explain what a variable is and state the rules for naming variables;
- identify the four major data types: integer, float, string and Boolean;
- use arithmetic, assignment and comparison operators correctly;
- read a simple Python script that uses variables, data types and operators together.
Why do programmers need variables, data types and operators?
Programmers need them because a program is a “To-Do List” for the computer, and the computer must be told what to remember and how to treat it.
- Short memory: the computer remembers only what the program tells it to store.
- Variables: hold the information the program needs.
- Data types: tell the computer what kind of information each variable holds.
- Operators: tell the computer what to do with the information.
- Languages: Python, Java and C++ all use these three tools.
What is a variable?
A variable is a named memory location that stores a value which can change while the program runs.
Think of a variable as a storage box in the computer’s memory.
- Moving house: you pack things into boxes and label them “Books”, “Kitchen Utensils” or “Clothes”.
- The box: the memory space.
- The label: the variable name.
- The stuff inside: the data (value).
What are the rules for naming variables?
A variable name must follow the rules of the language, and Python has the rules below.
- No spaces: use student_name, not student name.
- Start with a letter or underscore: you cannot start a name with a number, so 1score is wrong and score1 is correct.
- Use only letters, digits and underscores: total_cost is correct, total-cost is wrong.
- Remember that names are case-sensitive: age and Age are two different variables.
- Avoid reserved words: words such as if, for and while already have a meaning in Python.
- Good practice: be descriptive. Name a variable price, not just p, so you remember what it is for.
What are data types?
A data type tells the computer what kind of value a variable holds and what can be done with it.
- Why it matters: you cannot do maths on a word, and you cannot capitalise a number.
What are the four major data types?
The four major data types are integer, float, string and Boolean.
| Data type | Human name | What it is | Example |
|---|---|---|---|
| Integer (int) | Whole number | Numbers without decimals. | 10, -5, 2026 |
| Float | Decimal | Numbers with decimal points. | 10.5, 0.99, 3.14 |
| String (str) | Text | Letters, words or symbols in “quotes”. | “Hello”, “SS2”, “123” |
| Boolean (bool) | Logical | Only two values: True or False. | True, False |
Why is “123” a string and not an integer?
“123” is a string because it is written inside quotes, so the computer treats it as text.
- Quotes: anything inside quotes is a string, even if it looks like a number.
- Error: adding “123” + 7 causes an error in Python.
- Fix: change the string to an integer with int(“123”), then int(“123”) + 7 gives 130.
What are operators?
An operator is a symbol that tells the computer to perform a specific task on values.
- Verbs of programming: operators are the action words of a program.
- Operands: the values an operator works on, such as 10 and 5 in 10 + 5.
There are three groups of operators in this lesson: arithmetic, assignment and comparison.
What are arithmetic operators?
Arithmetic operators perform mathematical calculations on numbers.
| Operator | Name | Example | Result |
|---|---|---|---|
| + | Add | 10 + 5 | 15 |
| – | Subtract | 10 – 5 | 5 |
| * | Multiply | 10 * 5 | 50 |
| / | Divide | 10 / 2 | 5.0 |
- Division: in Python, / always gives a float, so 10 / 2 is 5.0 and not 5.
- Other Python operators: % gives the remainder (10 % 3 is 1) and ** gives a power (2 ** 3 is 8).
What is the assignment operator?
The assignment operator is the = sign, which puts a value into a variable.
- Meaning: in programming, = means “assign”, and it is different from the “equals” sign in maths.
- Example: age = 16 takes the number 16 and puts it in the box labelled age.
- Direction: the value on the right goes into the variable on the left.
What are comparison operators?
Comparison operators compare two values, and the answer is always True or False.
| Operator | Meaning | Example | Result |
|---|---|---|---|
| == | Equal to | 5 == 5 | True |
| != | Not equal to | 5 != 3 | True |
| > | Greater than | 3 > 5 | False |
| < | Less than | 3 < 5 | True |
| >= | Greater than or equal to | 5 >= 5 | True |
| <= | Less than or equal to | 6 <= 5 | False |
- = and ==: = stores a value, while == asks whether two values are equal.
How do variables, data types and operators work together?
They work together when a program stores values in variables and uses operators to calculate a result.
Here is a simple Python script:
Python
# 1. We create variables (boxes)
item_name = “Indomie” # This is a string
price = 250 # This is an integer
quantity = 3 # This is an integer
# 2. We use operators to do maths
total_cost = price * quantity
# 3. We show the result
print(item_name)
print(total_cost)
How does the computer read this script?
- The computer stores the string “Indomie” in the variable item_name.
- It stores the integer 250 in price.
- It stores the integer 3 in quantity.
- It multiplies price by quantity (250 * 3) and stores 750 in total_cost.
- It prints the value of item_name, which is Indomie.
- It prints the value of total_cost, which is 750.
- Comments: lines starting with # are notes for people, and the computer ignores them.
- Output: the screen shows Indomie on the first line and 750 on the second.
Evaluation
- Identify the data type for each of the following: 30.0, “Computer”, 45, True.
- Why is “123” a string and not an integer?
- What does the = sign mean in programming?
- Discussion: Why is it important to tell the computer the difference between an integer and a string?
Assignment
Write a simple formula using variables to calculate the area of a rectangle (Area = Length × Width). Give the variables values, and state the data type of each.
This term's Digital Technologies topics
SS2 Second Term · 8 topics
Get Digital Technologies as PDF and Word
Every week of SS2 Digital Technologies, Second Term, formatted and ready to print. Ad-free, and the copy lock comes off.
Get this term Card, bank transfer, USSD or OPay

