Python Number Data Type

Last updated Aug 08, 2021

Number Data Type

Integers, Floating-point, and complex numbers fall under the category of Number Data Type in Python Programming Language. All these number data types are written in the form of (int stands for integer, float stands for floating-point, and complex stands for complex numbers).

 

Integer Data Type

Basically, this data type is used for the integer value. We can also use a keyword for integer i.e. 'int'. Now we will take a look at the example of Integer Data Type:-

a = 5

print(a, "is of type", type(a))

 

5 is of type

As you can see that we had printed the type of data type and we found that it is of integer data type.

 

Floating Point Data Type

A floating-point or float data type is used for decimal numbers. The keyword which is used for floating-point integer is 'float'. Now we will take an example of floating-point data type:-



 

a = 5.4

print(a, "is of type", type(a))



 

5.4 is of type

As it is mentioned in the output that this is a floating-point number as it is in decimal form. 

 

 

Complex Number Data Type

The complex data type is the last form in number data type. This is used for complex values which are especially in the form of 'a+bj'. We will understand complex numbers with the help of an example:-


 

a = 5 + 2j

print(a, "is of type", type(a))

 

(5+2j) is of type

So you can see that when we entered a complex number we get its type as complex data type and it is always written in the form of a+bj.

So, these are the three types of numeric data types that are used in Python.

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

64 Views