INTRODUCTION TO PROGRAMMING
Download the Lessonotes Mobile Ghana app for faster lesson access on Android and iPhone.
Subject: Computing
Class: JHS 2
Term: 3rd Term
Week: 6
Grade code: B8.4.1.1.1
Strand code: 4
Sub-strand code: 1
Content standard code: B8.4.1.1
Indicator code: B8.4.1.1.1
Theme: COMPUTATIONAL THINKING
Subtheme: INTRODUCTION TO PROGRAMMING
This page supports the lesson note with a companion video and a short classroom-ready summary.
For class groups and homework, share this lesson page so learners also get the summary, objectives, and full lesson context.
Welcome, learners! Today, we are starting a very exciting journey into the world of programming. Think about the apps on your phone, like WhatsApp or the mobile money (MoMo) service. All these are created using instructions we give to a computer. This set of instructions is called a program. To write programs, we must first learn the "alphabet" and "grammar" of programming languages. This lesson introduces the most basic building blocks: Constants, Variables, and Operators. Understanding these is the first step to telling a computer what to do. Knowing this helps us understand how the technology we use every day in Ghana, from calculating a bus fare to using a banking app, actually works.
This lesson will focus on three fundamental concepts. Let's break them down one by one. A. Constants Definition: A constant is a value in a program that does not change while the program is running. It remains fixed from start to finish. Analogy: Think of the number of regions in Ghana. As of now, it is 16. This number is fixed and does not change day to day. In a program about Ghana's geography, the number of regions would be a constant. Ghanaian Context Example: The VAT (Value Added Tax) rate in Ghana is currently set at a specific percentage (e.g., 15%). When a program calculates the price of goods in a supermarket like Shoprite or Melcom, this VAT rate is a constant. It doesn't change for every item you buy. How it looks in simple code (Pseudo-code): ``` CONST NUMBER_OF_REGIONS = 16 CONST VAT_RATE = 0.15 ``` B. Variables Definition: A variable is a named storage location in a program that holds a value which can change while the program is running. Analogy: Think of a labeled empty bowl on a table. The label on the bowl is the variable's name (e.g., "My Age"). The item you put inside the bowl is the value (e.g., the number 14). Next year, you can take out 14 and put in 15. The bowl (storage location) and the label (name) stay the same, but the content (value) changes. Ghanaian Context Example: Your Mobile Money (MoMo) balance is a perfect example of a variable. When you receive money, the value increases. When you buy airtime or send cash, the value decreases. The name 'MoMo_Balance' stays the same, but its value changes frequently. How it looks in simple code (Pseudo-code): ``` LET studentAge = 14 // The student is 14 years old // Later, on their birthday... studentAge = 15 // The value of studentAge has now changed ``` The key difference: `CONST` values are fixed; `LET` or `VAR` values can be updated. C. Operators Definition: An operator is a special symbol that tells the computer to perform a specific mathematical or logical task. Today, we will focus on Arithmetic Operators, which are used for calculations. The Challenge: In programming, some symbols for these operations are different from what we use in our mathematics class. This is a very important difference to learn!
Comparison Table: Mathematics vs. Programming Arithmetic Operators (This directly addresses the NaCCA exemplar B8.4.1.1.1.1)
| Operation | Classroom Mathematics Symbol | Programming Symbol | Example in Programming | Result | | :--- | :--- | :--- | :--- | :--- | | Addition | `+` | `+` | `12 + 8` | `20` | | Subtraction | `-` | `-` | `25 - 10` | `15` | | Multiplication | `×` or `⋅` | `*` (asterisk) | `7 * 5` | `35` | | Division | `÷` or `/` or `Fraction Bar` | `/` (forward slash) | `40 / 8` | `5` | | Exponentiation (Power) | `3²` or `4³` | `` or `^` | `3 2` (means 3 to the power of 2) | `9` | | Modulus (Remainder) | Not a common symbol | `%` (percent sign) | `13 % 5` | `3` |
Detailed Explanation of Tricky Operators: Multiplication (`*`): We never use '×' in programming because it can be confused with the letter 'x'. We always use the asterisk `*`. So, `5 × 4` in math becomes `5 * 4` in code. Division (`/`): We use the forward slash for division. `20 ÷ 5` in math becomes `20 / 5` in code. Modulus (`%`): This might be new! The modulus operator gives you the remainder after a division. Example: `13 / 5` in math is 2 with a remainder of 3. Therefore, `13 % 5` in programming gives us the result `3`. This is very useful! For example, to check if a number is even, we can see if `number % 2` is 0.