Variables in Python Programming

In Python programming, data just like life around us changes. Someone said change is constant in everything. That means even change can change.

For example, scientists have agreed that when you wake up, you have a certain height that decreases until you sleep at night. Things that change are called variables in human language. The same thing is used in programming.

Think about your Facebook profile or IG for a moment. You can change your bio or profile picture anytime you want. That means the value of those things in the program varies. Also, the number of likes on a post varies. It cannot stay the same unless you have friends like me.

While some things cannot change anyhow, like your country location, or your house. Other things need to change, like your favorite clothes.

We use a variable in Python to write something that we might change. For example, the last time you took a girl’s phone number and saved it on your phone, you created a variable!

The girl’s name is the variable name, the phone number is the value. This is how the phone stores the variable:

Ariana_Grande = (+42) 555 675 865

You find that your age, for instance, is not the same as it was last year, or even last night if you permit yourself to go deeper.

Now, a variable in Python has three parts:

1. the variable name

2. the equal sign

3. the value

Let us declare your current age as a variable:

age = 10

You can type that in your IDE and keep it.

When you declare a Python variable, you tell Python that you will use this data in this program. Hold it for me.

Now you can use that variable, set a change parameter or simply display it with the print () function.

For example:

print (age + 1)

That code tells the script to change the variable by adding 1 and displaying the result. What do you get?

You have printed your first variable if you got 11 after Jason Derulo. Well done!

Variable Type

Now that you understand what variables are, you must understand how to use them.

We have learned that there are 3 parts to a variable. We will discuss three types of variables. Check the next tutorial to continue learning about variables.

Do you want to become an expert programmer? See books helping our students, interns, and beginners in software companies today (Click here)!

Leave a Comment

Python Tutorials