Variables, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
Variables in one minute
What students need to know
A variable stores a value under a name so it can be reused later, created with the assignment operator: name = 'Alice'. The name goes on the left, the value on the right. Once assigned, a variable can be read back or reassigned at any point, and Python figures out its type automatically from whatever's assigned to it.
Mistakes students make
- A single
=assigns a value; a double==compares two values — mixing them up (age == 15instead ofage = 15) is one of the most common beginner errors. - Variable names also can't start with a digit —
2scoreis invalid,score2is fine.
What students will learn in this module
Every question in Module 4
Quick questions
- What does
x = 5do?AChecks if x equals 5BStores 5 in x - After
name = 'Alice', what is stored inname?AAliceBname - Which is correct assignment?Aage = 15B15 = age
- What does
=mean in Python?AAssignBEquality - After
score = 100, what is stored inscore?AscoreB100
Key terms
Students type the meaning of:
name = 'Alice'
Match the pairs
3name = 'Bob'Match it to what it doesmy-score = 5Match it to what it doesname3 = 'Bob'Match it to what it doesmy_score = 5Match it to what it doesx = 10 print(x)Match it to what it does
name = 'Alice' print(name)Match it to what it does
Fill in the blanks
____ = 'Bob' print(name)
age _ 15 print(age)
score = 100 print(_____)
city = 'Melbourne' print(____)
___ = input('Enter Age: ') print(age)
Spot the error
Question 1
Aname = 'Alice'Bage == 15Cprint(name)
Question 2
Aname = 'Bob'B2score = 100Cprint(name)
Question 3
Aname = 'Alice'Bage = 15Cprint('name')
Question 4
Aage = 16Bstudent-name = 'Charlie'Cgrade = 11Dprint(student-name)
Question 5
Aname = 'Diana'Bage = 15Cschool = Parkdale HighDprint(school)
