Variables in Python.

Siddhiraj R. K.
3 min readMar 18, 2021

Variables in Python.

In this post we are going to study about Variables in Python. Let’s start..!

The first thing we have to understand What is variables ?

The variables is a very simple concept. Variables means a storage or memory in our program. for example you want to store some images then simply you will create a folder and you will save all that images in that folder. Here you need a folder to store that images. It means to store information or data you need something like file, folder etc. and in programming this is known as variable .

Variables stores data in program. Then How to create variables ?

Creating variables is very simple ex. fisrtNum , name , Roll_number , etc.

But to create variables in python should follow some rules.

1} Your variable name can be anything but should not be a Keyword . now What is Keyword ?

Keyword is a special word that already used in Python language. so we can’t use that keyword again as a variable. We can use keyword in our program but can’t use as a variable.

Here is a list of the Python keywords..

False , class , from , or, None , continue , global , pass , True , def , if , raise , and , del , import , return , as , elif , in , try , assert , else , is , while , async , except , lambda , with , await , finally , nonlocal , yield , break , for , not

You can’t use this keywords as your variable name.

2} You can’t start your variable name with number or special character except one character i.e. underscore ( _ ). You should start your variable name with alphabet or underscore only.

3} Your variable should not have any space in between. You can use underscore ( _ ) instead of space there.

4} You can use only alphabets , numbers and a single special character i.e. underscore ( _ ). To create a variable in python. You can’t use another special characters in your variable name.

5} Variables in Python are case sensitive. It mean capital A and small a are totally different. for example. Variable FirstName and firstName are not same. They are totally different variables.

Why we need variables ?

We need variables program to store information or data during execution of program. This variables are not permanent it means they stores data during the execution of program they lost their values or stored data after completing execution of program.

I have you noticed ? I have written a normal sentence in program starting with ‘#’. What is that ?

That is Comments. now What is comment ? , How to use comments in program ? and Why we need comments in program ? That we will see in next post.

If you have any doubts in this post then please ask me in comment section below. I will try to solve it.

Read more…

If you like these post and you have learned something from this then share this post with your friends and family.

Keep learning always…..!!! 😇😇😇

--

--