Fundamental or Primitive Data Types in Python


The most basic data types which are used to represent different data during programming are known as fundamental or primitive data types. Such data types contains pure and simple values of data.

Python programming language has four primitive or fundamental data types, namely, integers, floats, booleans and strings.

Quick Reference

Integer Data Types

Whole number from -∞ to +∞ are integer numbers. For example: 45, -90, 89, 1171 are integer numbers.

In python we can check the data type of any entity using built-in function type(). See example below:

Example 1:


print(type(1))

Output

<class 'int'>

OR

Example 2:


number = 100
print(type(number))

Output

<class 'int'>

In above examples both type() of 1 and type() of number is class of int.

Float Data Types

In python programming, float data types is used to represent floating point numbers. Example of floating point numbers are: -17.23, 78.99, 99.0 etc.

In python we can check the data type of any entity using built-in function type(). See example below:

Example 1:


print(type(17.23))

Output

<class 'float'>

OR

Example 2:


number = 100.0
print(type(number))

Output

<class 'float'>

In above examples both type() of 17.23 and type() of number is class of float.

String Data Types

In python programming, string data types is used to represent collection of characters. Characters can be any alphabets, digits and special characters. Example of strings are 'welcome to python', 'hello 123', '@#$$$' etc.

In python we can check the data type of any entity using built-in function type(). See example below:

Example 1:


print(type('Hello there!'))

Output

<class 'str'>

OR

Example 2:


string = 'Jack Daniels'
print(type(number))

Output

<class 'str'>

In above examples both type() of 'Hello there!' and type() of string is class of str.

Boolean Data Types

In python programming, Boolean data types is used to represent logical True and False

In python we can check the data type of any entity using built-in function type() like before. See example below:

Example 1:


print(type(True))

Output

<class 'bool'>

OR

Example 2:


number1 = 100
number2 = 200
result = 100 < 200
print(type(result))

Output

<class 'bool'>

In above examples both type() of True and type() of result is class of bool.

Additionally, python supports complex data type for manipulating different operations on complex number. We encourage you to read Understanding Complex Data Type in Python.