You are currently viewing Python Variables Types || Learn Python Step By Step
Learn Python Programming

Python Variables Types || Learn Python Step By Step

Introduction Variables and Its Types:

In a computer programming a variable is a small piece of storage location which identifying the memory. And it’s paired with associated symbol name (identifier). A variable is known or unknown as quantity of information referred to given value.

In other computer languages for example c ++, c# and java you may have observed before define the variable first you define the type of variable then assign the value. For example string mystring = ryk or int myInt = 11 or Dim price as Double but in python you don’t need to defined first the data type. You should declared a variable direct and assign its values.

After assigning a value to a variable python automatically understand the type of data which you have declared. For example

>>>> myInt = 11



python variable data type

After the declaration a variable and  give it value then press the enter and call the above variable the python automatically understand the data type which is string, int, double, float , decimal, date and whatsoever.

But when define a string variable but you assign a integer value the python IDLE give you  a error. For example

>>>>myInt = gsstech


Traceback (most recent call last):

  File “<pyshell#0>”, line 1, in

    myInt = gsstech

NameError: name gsstech is not defined

Python Variables Types


Int, Double, Float, Decimal, String, DateTime

Rules Of Variable Name In Python:

In python there are some  rules to declare a variable before define a variable you must follow these rules.

  1. A variable must start a letter or underscore_


>>> _age = 22

>>> _age



2. A variable must contain letter, number and underscore

3. A variable must have case sensitive

>>> MyInt

Traceback (most recent call last):

  File “<pyshell#7>”, line 1, in <module>


NameError: name ‘MyInt’ is not defined


The valid method  of declaration of a variable in python.

>>> age = 22


Don’t declare a variable with special simple for example @,#,$,%,^,& and *. In Python these simple are invalid. For example

>>>>#Int = 11

>>>>@Int = 11

>>>>$Int = 11



When you define a variable with wrong symbol the python ide don’t give you result. You cann’t access these types of variables.

.  You may define a variable with letter and number combination


>>> age = 22

>>> age22 = 22

>>> age22



But in python a variable cann’t start with a number. For example

>>> 22age = 22

SyntaxError: invalid syntax


The above method is totally invalid. Python ide prompt you that variable have syntax error.

When you define a variable with above simple the python automatically deduct and highlight with the red font. Its mean these method are invalid.

Reserved Words: || Python Variables Types

In python there are some reserved words you don’t use them in variable declaration. When you trying to use these reserved word the python will not give you result. These are following

And, del, for, is raise

Assert, elif, form, lambda, return

Break, else, global, not try

Class, except, if or while

Continue, exec, import, pass, yield

Def ?nally in print


If I declare variable from above word the pythom give me the syntax error. For example

>>> try = 22

SyntaxError: invalid syntax


>>> for = ryk

SyntaxError: invalid syntax


Please note while you writing these words the python automatically change its color orange and you can’t use them.

Rules of declaration of variables in python:

In python you must follow the rules before deflation of a variable. For example

Integer Variable

>>> myInt = 13

>>> myInt



Float Variable

>>> myFloat = 15.8

>>> myFloat



In python you may also assign a complex value to a variable which may be either string and number. These are also valid. For example

>>> myComplex = 25j

>>> myComplex



You may access the  power of any number in python be declare in variable. For example

>>> myNum = 2e5

>>> myNum



Conclusion: || Python Variables Types

Python language  is a easy to understand . In python learning there are no need to have other languages such as C#, Java, Php, C++, ASP.Net, VB.Net. Because its syntax so easy. In python variables types there are no need to write a long phrase for declare a variable.  

This Post Has 3 Comments

  1. dizi izle

    Hello. Great job. I did not imagine this. This is a great story. Thanks! Rianon Dore Seow

Comments are closed.