Subject: ICT Class: 10 A&B Duration: 40 Minutes (1 period)
Lesson 4 - Q2 Cognia Standards & Benchmarks
Strand: Coding
Competency: Solve multiple problems by using algorithms and programming
language to enhance computational thinking and build a positive attitude towards
coding.
Topic: Advanced Variables (programiz)
Objectives: At the end of the lesson, each student should be able to:
● gain a deeper understanding of the concept of variables.
● create and change the value of a variable.
● differentiate between number and string variables and how to use them in
Python.
● use arithmetic operators like +=, -+ to concatenate strings.
● complete Exercises .
Prior Knowledge
● if-else conditional statement
● in operator (Exercises )
Lesson Description
In this lesson, students are introduced to advanced variable concepts in Python to
improve their computational thinking and coding skills. The objectives of the lesson
comprise modifying and generating variable values, distinguishing between
number and string variables, and concatenating strings using arithmetic operators.
The session commences with an interactive task to demonstrate the function of
variables and containers. Following that, the students learn about variable syntax
and its usage in the Coding Chatbots exercise. The lesson comprises two activities
that concentrate on utilizing operators to concatenate variables and completing
exercises . The crucial takeaways from this lesson include the understanding that
variables have a name for identification, hold values, and can only hold one value
of one type at a time. Students watch a video on python variables & data types,
and read an article on python string concatenation as a part of an extended learn-
ing activity.
Introduction 10 mins
We will demonstrate what swapping values means through the
representation of different beverages in cups.
In this activity, you need 3 glasses, 2
containing different-colored drinks (i.e.
orange juice and water).
Ask the class how you can switch
between the two liquids. - use the
third empty cup.
● This is a metaphor for swapping
values contained in variables.
● In order to swap variables, we need to use a third temporary
variable.
If the class is familiar with variables swap with using a temp variable,
present the following code. Ask the class what will be the output and go
line by line to follow the code and variables values.
var_1 = 5
var_2 = 7
var_1 = var_2 + var_1
var_2= var_1 - var_2
var_1 = var_1 - var_2
send_message(var_1)
send_message(var_2)
Learning Experiences 20 mins
Activity 1: Using operators to concatenate variables
This part correlates to Exercise 15. The variable value can change along
the program. Assigning new value as follows:
my_var = "snowman”
my_var = "Python”
Assigning value from input:
my_var=read_message()
Assigning value from input or programmer-defined can be done in any
place in the code. Once the value has changed the previous value no
longer exists.
Concatenate is to link strings and characters together in a chain or
series.
Strings can be changed by adding additional characters to an existing
string. The + operator concatenates two strings.
Ask the class what will be the value of the variable ‘name’ after each of
the following instructions.
name = "Pyth"
letter_1 = "o"
letter_2 = "n"
name = name + letter_1
name += letter_2
Emphasize the ability to use the long and short versions of the
concatenate operator as presented in this example.
Numeric variables in Python are used to store numbers as integers or
floating (rational) numbers. Variables can hold a single value of a
single type at a time.
my_var_1 = 5 number
my_var_2 = "5" string
The arithmetic operators in Python are used to perform mathematical
operations such as addition, subtraction, multiplication, and division. In
this lesson, we will focus on addition and subtraction.
What will the output be?
my_var = 0 holds 0
my_var = 3 holds 3
my_var += 1 holds 4
my_var -= 2 holds 2
my_var_1 += 75 holds 80
my_var_2 += "75" holds "575”
Emphasize the ability to use the long and short versions of the
concatenate operator as presented in the example above.
Activity 2: Solving Exercises
Ask students to complete Exercises. Encourage them to go step
by step. Make sure they use the exact text required in the exercises.
Use your classroom’s dashboard to keep track of students’
achievements.
Assessment/Closure 10 mins
Invite a few students to come to the front of the class and share how
they have solved Exercises. Ask them to explain the codes they used
for solving these exercises.
Key Points:
● Variables hold values, the actual data that is being stored in
memory.
● Variables have names so programmers and the computer know
which variable is called on.
● Do not confuse variable names with their values.
● A variable can only store one value of one type at a time.
● When you change the value (or the type) in a variable, you
destroy anything that was previously there.
● Assigning the value 5 to a variable will be treated as a numeric
data type. However, assigning the value "5" (in quotes) to the
same variable would be treated as a string data type.
● Numeric values are used for mathematical operations, while
string values are processed through string manipulation
functions.
Do It Yourself
1. Let students watch “Python Variables and Data Types” starting from 4:00 -
8:45 minutes to explore how to string and numeric (integer and floating
numbers) values are assigned to variables. Let them create two examples
each for these types and ask them to write in their notebook.
2. Let students refer to the web “Python String Concatenation” and make notes
on using the + operator to concatenate strings. Instruct students to create
two more examples of their own and write them in their notebooks.
3. Let students revisit Exercises . Tell them to complete the bonus task in
order to ensure that they get 100% in level completion at the end of the
course. Let them know that their work progress would be monitored via the
PROGRAMIZ plateforme.