Python Data Types

We'll cover the following

Python data types

Python data types are used to define the type of the variable. Variables can store different values, and Python data types identify what type of data is stored in the variable. There are a few built-in data types in Python. Let’s have a look at them.

Data types

Data Type

Classes

Summary

Numeric

int

The int data type holds whole numbers, both positive and negative.

float

The float data type represents real numbers, including decimal points.

Complex

The complex data type represents complex numbers, consisting of a real part and an imaginary part.

Text

str

The str data type is used to store characters, commonly known as strings.

Sequence

list

The list data type is used to store ordered collections of items, which can be of different types.

tuple

The tuple data type holds an ordered collection of items, similar to a list, but it is immutable (cannot be modified after creation).

range

The range data type represents a sequence of numbers, typically used in loops for iteration.

Boolean 

bool

The bool data type is used to represent Boolean values which are either True or False.

Set

set

The set data type is used for storing unordered collections of unique items.

frozenset

The ‘frozenset’ data type in Python is used for storing an immutable and unordered collection of unique items.

Mapping

dict

The ‘dict’ data type is used to store data values in key:value pairs, forming a mutable and unordered map.

None 

NoneType

The ‘NoneType’ represents the absence of a value and is denoted by the singleton ‘None’.

Python data types can be either primitive data types or compound data types. Let’s first learn what these signify and then move through various examples to clear up our concepts!