Computer Programming II – SS2 Digital Technologies Lesson Note (Second Term)
Lesson note at a glance
- Class
- SS2
- Subject
- Digital Technologies
- Term
- Second Term
- Reading time
- 5 min
Python is a programming language that lets us write English-like instructions and have the computer carry them out. The computer only understands 1s and 0s, so Python acts as the translator.
Behavioural objectives
- Explain why Python is used as a programming language.
- Use the print() function to display text and results.
- Create variables and give them values.
- Identify the string, integer, float and Boolean data types.
- Use basic operators, and state the difference between = and ==.
- Use the input() function to ask the user for information.
What is a programming language?
A programming language is a set of words and symbols used to give instructions to a computer.
- Machine language: the computer only understands electrical signals, written as 1s and 0s.
- Translator: a language like Python converts our English-like code into something the computer can execute.
- Link to the last lesson: we planned programs with algorithms and flowcharts. Now we write the code.
Why is Python used?
- Easy to read: the code looks close to plain English.
- Wide use: companies such as Google, NASA and Netflix use it.
- Easy to start: a beginner does not need advanced maths.
How do you display output with print()?
The print() function displays text or results on the screen.
Example:
print(“Hello, SS2 Students!”)
- Function name: print is written in lowercase.
- Brackets: the item to display goes inside ( ).
- Quotation marks: text inside “” is a string. Python displays it exactly as written.
- Numbers and sums: print(5 + 2) shows 7, but print(“5 + 2”) shows 5 + 2.
What is a variable?
A variable is a named place in the computer’s memory where data is stored.
- Box example: you put books in a box and write “BOOKS” on it. The label helps you find the box later.
- Name: the label on the box.
- Value: the item inside the box.
Example:
user_name = “Chidi”
age = 16
- user_name: the label on the box. “Chidi” is the item inside.
- age: the label on another box. 16 is the item inside.
What are the rules for naming a variable?
- No spaces: use an underscore, as in user_name.
- No number first: name1 is allowed, but 1name is not.
- Case matters: Age and age are two different variables.
- Meaningful names: choose names that describe the data, such as age or result.
What are data types?
A data type tells Python what kind of data is stored in a variable. There are four basic data types: string, integer, float and Boolean.
| Data type | What it is | Example |
|---|---|---|
| String (str) | Text or characters (always in quotes). | “Lagos”, “Apple123” |
| Integer (int) | Whole numbers (no decimals). | 5, -10, 1000 |
| Float | Decimal numbers. | 15.5, 0.75 |
| Boolean (bool) | True or False values. | True, False |
- Quotes matter: “16” is a string, but 16 is an integer.
- Boolean spelling: True and False start with a capital letter and have no quotes.
- Checking a type: type(age) tells you the data type of age.
What are the basic operators?
An operator is a symbol that tells Python to perform an action on values or variables.
Arithmetic operators
| Symbol | Operation | Example | Result |
|---|---|---|---|
| + | Addition | 5 + 2 | 7 |
| – | Subtraction | 5 – 2 | 3 |
| * | Multiplication | 5 * 2 | 10 |
| / | Division | 10 / 2 | 5.0 |
| ** | Power | 2 ** 3 | 8 |
| // | Whole-number division | 7 // 2 | 3 |
| % | Remainder | 7 % 2 | 1 |
- Division answer: / always gives a float, so 10 / 2 is 5.0.
- Joining text: + joins two strings, so “Good” + “day” gives “Goodday”.
Comparison operators
- ==: is the left side equal to the right side?
- !=: is the left side not equal to the right side?
- > and <: is the left side greater than, or less than, the right side?
- Result: a comparison always gives True or False, for example 5 > 3 is True.
What is the difference between = and ==?
- Single equals sign (=): the assignment operator. It puts a value into a variable.
- Double equals sign (==): the comparison operator. It checks whether two things are the same.
| Point | = | == |
|---|---|---|
| Job | Assigns a value | Checks equality |
| Example | age = 16 | age == 16 |
| Result | age now holds 16 | True or False |
How do you get input from the user?
The input() function shows a message, waits for the user to type, and returns what was typed.
Example:
name = input(“What is your name? “)
print(“Welcome to the class, ” + name)
- Python displays the message “What is your name? “.
- The user types a reply and presses Enter.
- Python stores the reply in the variable name.
- print() displays the welcome message with the name.
Why must you convert input before using it in sums?
- Input is always a string: even if the user types 16, Python stores “16” as text.
- int(): changes a string into an integer, so sums become possible.
- str(): changes a number into a string, so it can be joined to text with +.
Example:
age = int(input(“How old are you? “))
print(“Next year you will be ” + str(age + 1))
What are common beginner errors?
- SyntaxError: a rule is broken, such as a missing quotation mark or bracket.
- NameError: a variable name is misspelt or used before it was created.
- TypeError: a string and a number are joined with +, such as “Age: ” + 16.
Class lab activity
- Open the Python IDLE (the program where we type code).
- Task 1: Write a program that prints your name and your favourite food.
- Task 2: Create two variables, num1 and num2, with values such as 10 and 20. Create a third variable called result that adds them and prints it.
- Task 3 (Challenge): Write a program that asks for a student’s name and age, then prints: “Hello [Name], you will be [Age + 1] next year!” Use int() to convert the age and str() to join it to the text.
Evaluation
- Why do we need a programming language like Python to communicate with a computer?
- What is a variable? Using the box example, explain what the name and the value stand for.
- Name the four data types in the lesson and give one example of each.
- What is the difference between = and == in Python?
- State the job of print() and the job of input().
Assignment
- Write a Python program that stores your name in a variable called user_name and your age in a variable called age. Print your name, then print your age plus 5. Add a comment line naming the data type of each variable, and write one example each of a string, an integer, a float and a Boolean value.
This term's Digital Technologies topics
SS2 Second Term · 8 topics

