Variables, online

Six activities your students do on their own devices. See who's finished, and their scores.

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 == 15 instead of age = 15) is one of the most common beginner errors.
  • Variable names also can't start with a digit — 2score is invalid, score2 is fine.

Discover other journeys with this module

What students will learn in this module

Every question in Module 4

Quick questions

  1. What does x = 5 do?AChecks if x equals 5BStores 5 in x
  2. After name = 'Alice', what is stored in name?AAliceBname
  3. Which is correct assignment?Aage = 15B15 = age
  4. What does = mean in Python?AAssignBEquality
  5. After score = 100, what is stored in score?AscoreB100

Key terms

Students type the meaning of:

  • name = 'Alice'

Match the pairs

3name = 'Bob'Match it to what it does
my-score = 5Match it to what it does
name3 = 'Bob'Match it to what it does
my_score = 5Match it to what it does
x = 10
print(x)
Match it to what it does
name = 'Alice'
print(name)
Match it to what it does

Fill in the blanks

  1. ____ = 'Bob'
    print(name)
  2. age _ 15
    print(age)
  3. score = 100
    print(_____)
  4. city = 'Melbourne'
    print(____)
  5. ___ = 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)