Variables in Python
PAGE 18 AND 19 FROM BOOK
Learning Objectives
By the end of the lesson, students will be able to
• Analyze the concept of variables in programming for storing and
managing data.
• Evaluate the effectiveness of variable naming in making code readable.
What are variables?
Variable is a named memory location used to store data of a
given type during program execution.
How do we assign a value to a variable?
We simply use the equal sign (=) as an assignment operator, followed
by the value you want to assign to the variable. Here's an example:
Country=“UAE”
Rules for naming variables
1. Variable names must start with a letter or an underscore ( _ )
character.
2. Variable names can only contain letters, numbers, and underscores.
3. Variable names cannot contain spaces or special characters.
Variable naming conventions
Variable names should be descriptive and not too short or too long.
Use lowercase letters and underscores to separate words in
Variable names (known as "snake_case").
Extended Task:
Assign a value as 3 to the variable glass_of_water and display the
message I drank 3 glasses of water today.
Exit Ticket:
Why do programmers use variables
instead of writing values directly?
Answer the following questions:
What are variables?
Write the rules for naming the variables.
Answer the Exit ticket question.
Do the extended task.
Do the individual task.
Other Resource:
https://www.youtube.com/watch?v=e5Yv5uG4
kZk
Scan and play the quiz.