Lesson 6 : Variables
Challenge focus: 41 - 47
Coding Concepts : variables
December 2023
Banana Tales I
Key stage III
Class VII
LESSON OVERVIEW
CODING CONCEPT | Variable | ||||||
CHALLENGE | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
SUB CONCEPTS |
| ||||||
RESOURCES | Lesson Plan 26 Variables |
December 2023
Banana Tales I
Key stage III
Class VII
Lesson Objectives
At the end of the lesson, each child should be able to:
December 2023
Banana Tales I
Key stage III
Class VII
Understanding Variables
December 2023
Banana Tales I
Key stage III
Class VII
Understanding Variables
my_name = “Tshewang”
my_num= 23
my_menu=[“chicken”, “Rice”, “egg”]
Variable name
String
Number
List
Assignment operator
December 2023
Banana Tales I
Key stage III
Class VII
Understanding Variables
Example:
my_var = 2
Change the value:
my_var = 5
Now the value of my_var is 5.
December 2023
Banana Tales I
Key stage III
Class VII
Variable Naming Rules
Variable name must start with a letter (a-z, A-Z) or an underscore (_).
Example: name, _name
Reserved keywords cannot be used as a variable name.
Example: print, for, in, and, or, etc
Variable names cannot contain spaces or most special characters, except underscores (_).
Example: first name, name#123
A variable name cannot start with a numeric value.
Example: 89age, 123name.
Variable names are case-sensitive.
Example: age and Age are different.
Variable naming
Coding Adventure Part I
Key stage II
Class IV
Activity 1
Study the challenge given below to answer the questions. (challenge 41):
December 2023
Banana Tales I
Key stage III
Class VII
Activity 1 Solution
1 2 3 4 5 | goal_length = snakes[3].length print(“goal_length is:”) print(goal_length) for index in range(3): snakes[index].length = goal_length |
December 2023
Banana Tales I
Key stage III
Class VII
Demo 1
Study the given challenge below carefully and answer the questions that follows (challenge 42).
1 2 | for i in range(1, 8): ……………………………………. |
December 2023
Banana Tales I
Key stage III
Class VII
Demo 1 Solution
1 | height = giraffes[0].height |
2 | print(“The height of the first giraffe is”,height) |
1 2 3 | height = giraffes[0].height for i in range(1,8): giraffes[i].height = height |
Coding Adventure Part I
Key stage II
Class IV
Activity 2
Study the given challenge below and answer the questions that follow (challenge 45).
December 2023
Banana Tales I
Key stage III
Class VII
Activity 2 Solution
Ans: There are two variables. They are height and giraffe.
Iteration | Value of h | Value of g |
1st | h = 4 | g = giraffes[0] |
2nd | h = 5 | g = giraffes[1] |
3rd | h = 6 | g = giraffes[2] |
4th | h = 7 | g = giraffes[3] |
5th | h = 8 | g = giraffes[4] |
6th | h = 9 | g = giraffes[5] |
December 2023
Banana Tales I
Key stage III
Class VII
Activity 3
December 2023
Banana Tales I
Key stage III
Class VII
Activity 3 Solution
44
December 2023
Banana Tales I
Key stage III
Class VII
Activity 3 Solution
46
December 2023
Banana Tales I
Key stage III
Class VII
Activity 3 Solution
47
December 2023
Banana Tales I
Key stage III
Class VII
Key Points
December 2023
Banana Tales I
Key stage III
Class VII