Skip to content

Data Types in Python

Python – Data Types

If you have not read the Python Variables, then first you read it, only then proceed or else you will understand further. As we read earlier variables are a very important concept in all programming languages. Similarly, Data Types in Python are also considered to be a very important concept in computer programming and from here your real Python programming begins. So let’s start reading about data types.

What are Data types in Python ?

Data type is a technique by which we can reserve memory block into RAM is known as data type. In computer programming language, data type is an most important concept. 

Note : Data types are used to define variable and variables are used to hold data.

What are the types of Data types ?


Python has the following built in data types are :

1. Single value data type consists of :

 Python Numeric Datatypes
          → Int
          → float
          → complex

 Python String Datatype
          → str

2. Collection of datatypes consists of :

⇒ List
⇒ Tuple
⇒ Dictionary
⇒ Set
⇒ Frozen set

Python Numeric Datatypes

Numbers datatype stores only Numeric values. The numbers objects are created when you assign a value to them. 

Example :

variable_1 = 5
variable_2 = 10

Python supports three different Numerical type :

→ Int ( signed integers )
→ Float ( float point values )
→ Complex ( complex numbers )

Example : Here are the examples of Python Numeric Data types.

-550-50.502.366e – 50j
05052.3 + 15.596j
-0590-59.-5213 + 0j
  •  A complex number consists of an ordered pair of real floating – point numbers denoted by x + y, where x and y are the real numbers and j is the imaginary unit.

Python String Datatype

String in python are identified as a contiguous set of characters represented in the quotation marks. Python allows you either pairs of single or double quotes. 

Example :

str = 'Hello CodifyShow !!'

str = "Hello CodifyShow !!"

str = """welcome

Output :

Hello CodifyShow !!
Hello CodifyShow !!
CodifyShow !!

Setting the Data type

In python programming, the data type is set when you assign a value to a variable.

Example Datatype
x = 20Int
x = 20.5Float
x = 2jComplex
x = “Hello CodifyShow”str
x = [“Black” , “White” , “Red”]List
x = (“Black” , “White” , “Red”)Tuple
x = {“Name” : “Steve” , “age” : “30”}Dictionary
x = {“Black” , “White” , “Red”}Set
x = ({“Black” , “White” , “Red”})Frozen set

How to check data type in Python ?

If you want to identify the data type, then you can use the below statement.

Example :

x = "Hello CodifyShow !!"

Output :

<class 'str'>