Get startedGet started for free

Variable Assignment

In Python, a variable allows you to refer to a value with a name. To create a variable x with a value of 5, you use =, like this example:

x = 5

You can now use the name of this variable, x, instead of the actual value, 5.

Remember, = in Python means assignment, it doesn't test equality! Try it in the exercise by replacing ____ with your code.

This exercise is part of the course

Introduction to Python

View Course

Exercise instructions

  • Create a variable savings with the value of 100.
  • Check out this variable by typing print(savings) in the script.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create a variable savings
____

# Print out savings
____
Edit and Run Code