Editor settings

General settings

Save settings

Learn to program with Python

Variable Declaration #

In programming, declaring a variable is a way of storing data in a variable so that we can use it later. Imagine a variable as a box that can store something inside. In the Python language, we can declare a variable using the equal sign =. For example:

a = 1

This is declaring the value of 1 to the variable named a. When the code is executed, we can use a to do something else, as shown in the example below:

a = 1
print(a) # Output: 1

Exercise #

  • Create a new variable x and assign the number 10 to it.
Output will be displayed here