Skip to content

Programming Basics – SS2 Digital Technologies Lesson Note (Second Term)

Download this term · ₦1,000

Lesson note at a glance

Subject
Digital Technologies
Class
SS2
Term
Second Term
Topic
Programming Basics
Order
Topic 3 of 8 this term
Reading time
3 min

A computer program is a list of instructions for the computer. To manage information, every programming language, such as Python, Java or C++, uses three main tools. Variables are memory locations that store data. Data types tell the computer whether data is a number, text or a logic value. Operators are symbols that add, compare or assign data.

Advertisement

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?

When we write a computer program, we are basically giving a “To-Do List” to the computer. However, the computer has a very short memory unless we tell it exactly what to remember and how to remember it.

To manage information, every programming language (whether it is Python, Java or C++) uses three main tools: variables, data types and operators.

What is a variable?

Think of a variable as a physical storage box in the computer’s memory.

If you are moving house, you do not just throw everything into a truck. You put things in boxes and write labels on them like “Books”, “Kitchen Utensils” or “Clothes”.

In programming:

  • The box is the memory space.
  • The label is the variable name.
  • The stuff inside is the data (value).

Rules for naming your “boxes”

  1. No spaces: Use student_name, not student name.
  2. Start with letters: You cannot start a name with a number.
  3. Be descriptive: Name your variable price, not just p, so you remember what it is for.

What are data types?

A computer needs to know what is inside the box so it knows what to do with it. You cannot perform maths on a word, and you cannot capitalise a number.

Here are the four “major flavours” of data:

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
Advertisement

Teacher’s note: Notice that “123” is a string, not a number. Because it has quotes, the computer treats it like a word. Trying to add “123” + 7 would cause an error.

What are operators?

Operators are symbols that tell the computer to perform a specific task. They are the “verbs” of programming.

Arithmetic operators (the maths guys)

  • + (Add): 10 + 5 → 15
  • – (Subtract): 10 – 5 → 5
  • * (Multiply): 10 * 5 → 50
  • / (Divide): 10 / 2 → 5.0

Assignment operator (the “put in box” guy)

The = sign is the most used symbol. In programming it means “assign”, and it is different from the “equals” sign in maths.

  • age = 16 (Take the number 16 and put it in the box labelled ‘age’).

Comparison operators (the decision guys)

These are used to compare two boxes. The answer is always True or False.

  • == (Equal to): Is 5==5? True.
  • != (Not equal to): Is 5!=3? True.
  • > and < (Greater than and less than).

How do variables, data types and operators work together?

Here is how these three things look when they work together in 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)

Evaluation

  1. Identify the data type for each of the following: 30.0, “Computer”, 45, True.
  2. Why is “123” a string and not an integer?
  3. What does the = sign mean in programming?
  4. 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).

This term's Digital Technologies topics

SS2 Second Term · 8 topics

  1. Computer Programming I
  2. Computer Programming II
  3. Programming Basics
  4. Control Structure
  5. Data Science Basics
  6. Big Data and Analytics
  7. Artificial Intelligence
  8. Machine Learning Basics
Downloads

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

Advertisement

Lesson Notes for Other Classes

Print it or edit it in Word

Every note is free to read online. A PDF or Word copy of one subject costs ₦1,000 for one term, or ₦2,000 for all three terms.

Continue with GoogleContinue with Facebook

Sign in first, then choose your class and subject at checkout.