Learn practical skills, build real-world projects, and advance your career

Storing information using variables

Computers are useful for two purposes: storing information and performing operations on stored information. While working with a programming language such as Python, informations is stored in variables. You can think of variables are containers for storing data. The data stored within a variable is called it's value. It's really easy to create variables in Python, as we've already seen in the previous tutorial

my_favorite_color = "blue"
my_favorite_color
'blue'

A variable is created using an assignment statement, which begins with the variable's name, followed by the assignment operator = (different from the equality comparision operator ==), followed by the value to be stored within the variable.

You can also values to multiple variables in a single statement by separating the variable names and values with commas.

color1, color2, color3 = "Red", "Green", "Blue"