Variables

Module 2 · Variables · Lesson 8 of 8

Quiz

Five questions on naming, assignment and reassignment. Work each one out in your head first — then see if you're right.

1

Which of these is a valid variable name?

2

What does this print?

x = 5
x = x + 3
print(x)
3

After this runs, what is n?

n = 10
n += 5
4

What is printed?

x = 7
y = x
x = 2
print(y)
5

score was never created. What happens?

print(score)

That's variables done — you can store data, name it, reuse it, and change it. Combined with operators, that's genuinely enough to write useful little programs.