Data type is a keyword that is used to specify the kind of data that a data element is holding. The datatype is also useful in many other places like functions, Class declarations etc.

Python has the following data types built-in by default, in these categories:

Text Type : str

Numeric Types : int, float, complex

Sequence Types: list, tuple, range

Mapping Type : dict

Set Types : set, frozenset

Boolean Type : bool

Binary Types : bytes, bytearray, memoryview

You can get the data type of any object by using the type() function

Example:

x = 5

print(type(x))

**Type Conversion**

Sometimes, you may need to perform conversions between the built-in types. To convert between types, you simply use the type name as a function.

Eg:

x=int(10.2)

**Number Data Types**

Number data types store numeric values. They are immutable data types, means that changing the value of a number data type results in a newly allocated object.

Number objects are created when you assign a value to them.

Eg:

var1 = 1

var2 = 10

You can also delete the reference to a number object by using the del statement. The syntax of the del statement is −

del var1[,var2[,var3[….,varN]]]]

Eg:

del var1

del var1, var2

**Different number data types:**

int (signed integers) − also known as integers or ints, are positive or negative whole numbers with no decimal point.

long (long integers ) − alternatively called longs, they are integers of unlimited size, written like integers and followed by an uppercase or lowercase L. (recommended to use upper case L)

float (floating point real values) − real numbers and are written with a decimal point dividing the integer and fractional parts. Floats may also be in scientific notation, with E or e indicating the power of 10 (2.5e2 = 2.5 x 102 = 250).

complex (complex numbers) − are of the form a + bJ, where a and b are floats and J (or j) represents the square root of -1 (which is an imaginary number). The real part of the number is a, and the imaginary part is b. Complex numbers are not used much in Python programming.