Variables declaration and their uses in python development

In my last tutorial, we have familiar with the python introduction to a quick start for development. We have learned how to install the python and set the python environment for all platform. If you not checked then I would be recommended to check this tutorial first for better understanding. Here is the link to the introduction and how to install and what is the best IDE can we use for development.

Now in this tutorial, we will learn how to declare a variable and their uses in python. So let’s get started to learn. Variables are just parts of your computer’s memory where you store some information. Unlike literal constants, you need some method of accessing these variables and hence you give them names. As we know that any programming language has two known variables that are called local and global. A local variable scope is inside the function definition while global variable can access every function of a class.

Variable Assignment:  We use the assignment operator (=) to assign values to a variable. For example, let’s see and string assigns into a variable.

Output result: This is my first variable

Similarly, we can be assigned the integer, float and boolean into the variable. Here is the example to understand.

Output result: 20, 30.4 and True.

Let’s see how can use the sum and divide number and store into the variable?

Output result: 3.3333333333333335 and 10

Even we can use the multiple variable assignments also.

Let’s see the example of local and global variables to define in python.

Output result:

This is global variable.
This is my local variable
This is global variable.

Now let’s check with modified with a local and global variable for better understanding that how it works.

Output result:


Great Now we have the clear understanding of the variable declaration in python and their uses. In my next tutorial, we will learn what are the data types available in python and their use cases.

If you are wondering to learn Android then Please Learn from Android category and Wondering to lean Kotlin then Kotlin Category will help you.

Please do subscribe your email to get the newsletter on this blog on below and if you like this post then do not forget to share like and comment on below section.

Happy coding 🙂

I am a very enthusiastic Android developer to build solid Android apps. I have a keen interest in developing for Android and have published apps to the Google Play Store. I always open to learning new technologies. For any help drop us a line anytime at

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.