Variables and Data types in Python

Python is an all-rounder programming language which deals with several types of basic fundamentals, these are going to use to develop Python programs which include variable, identifiers, data types, strings arrays, etc..

Let us understand one by one as follow:

Python Identifiers:

A name which represents Variable, class, Function, Method name or Object which is used for identification purpose is called as Identifier

  • Identifiers can be in Lowercase(a to z),
  • Uppercase(A to Z), and digits(0 to 9)
  • It can be an Underscore( _ )

Ex: valid examples


Invalid examples


Just see the below example


Some Rules for Python Identifiers :

  • Where the identifier does not include any special characters like $,%,&, *,etc..
  • Identifier names never start with Digits
  • Python Identifiers are the case sensitive
  • There is no length limit for Python Identifiers
  • Even though there is no length limit for identifiers we should not use unnecessarily too lengthy identifiers
  • In Python there are some reserved words are there which we cannot use to declare the variables
  • If any variable starts with _x is called a protected variable
  • If any variable starts with two underscores __x is called a private variable
  • If any variable starts with two underscores and ends with two variables is called as Magic variable __x__

Python keywords :

The words which are used to represent the syntax and Structure of the python language is called as Keywords or Python Reserved words.

  • Keywords are case sensitive
  • there are 33 keywords in Python language
  • All the keywords except True, False and None are in the lowercase

The list of Keywords are as follows :

False class finally is return
None continue for lambda try
True def from nonlocal while
and del global not with
as elif if or yield
assert else import pass
break except in raise
  • All the keywords contain only alphabet symbols
  • let us see some examples:

  • Python is a dynamically typed language and hence it does not require any int, float, complex type of reserved words.
  • There is a keyword module in Python, we can import them as shown below:

    import keyword

    If you enter the above command it will list out all the keywords which are present in the keyword module


Introduction to Python Datatypes

Data type: It represents the type of data stored in a variable which is used in our program is called as Datatype.

Python is a Dynamically typed programming language and hence we are not required to define the types of the Data explicitly

Based on the assigned value the type will be considered by the python virtual machine, and also there will be a function called type(a) which represent the data type of a.


  • Int type

  • Boolean type

  • Float type

Different data types available in Python

There are 14 types of Data types are present in the Python



2 float
3 complex
4 boolean
5 string
6 list
7 tuple
8 set
9 frozenset
10 dict
11 bytes
12 bytes array
13 range
14 none
Note: Everything in the Python is an Object

There are three inbuilt functions are there in the Python :

Consider an example where we are assigning a value to an a=10

  • And if we want to know the type of a, we will use type(a) and then it will display the data type of a
  • And if we want to know the address of a that means where it is located then we will use id(a)
  • And if we want to print the value of a, we will use print(a)

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions