Theory

A variable is a name that refers to a value stored in computer memory.

To create a variable, use the = sign:

name = "Alice"
age = 25

The variable name is on the left, and the value is on the right.

You can then use variables in print():

print(name) # Will display: Alice
print(age) # Will display: 25

Exercises in this lesson

2

Number Variable

Create a variable called 'age' with the value 10 (a number, not text!) and display it. Note: Numbers don't need quotes!

Easy Points: 10
3

Two Variables

Create two variables: - 'name' with your name - 'city' with your city Display both on separate lines.

Easy Points: 15
4

Change Variable

Create a variable 'x' with value 5, then change it to 10, and display the result. The output should show only 10 (the final value).

Easy Points: 15
Solve in the playground
Next lesson: Math Operations →