Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Displaying values
Variables
6. Creating variables
The print function
List basics
Summary

Instruction

Good! Let's move on to variables. Variables in programming languages are a bit like cells in Excel: they store some data. In Excel, cells have strict names like A4 or B11. In Python, variables can have any names you want:

current_age = 25

This line of code:

  • creates a new variable named current_age,
  • assign the value of 25 to current_age.

The equals sign (=) means "assign the value of the stuff on the right to the variable on the left" in Python. It's very important – you cannot assign things the other way round.

Exercise

Create a variable called temperature, assign a value of 15 to it.

Stuck? Here's a hint!

You will need to create the variable and assign the value.

temperature = 15