Primitive Data Types vs Non Primitive Data Types in Python

Last Updated : 16 Jul, 2026

Python is a versatile, dynamic language. While it doesn’t explicitly categorize data types as “primitive” or “non-primitive” like Java, understanding these concepts helps organize and manage data efficiently.

Primitive Data Types

Primitive data types are the basic data types that store a single value. These data types are immutable, which means their values cannot be modified after they are created. Commonly used primitive data types are:

  • int: Stores whole numbers, such as 10 and -25.
  • float: Stores decimal numbers, such as 10.5 and 3.14.
  • bool: Stores one of two values: True or False.
  • str: Stores a sequence of characters enclosed in single or double quotes.

Example: Here, we create variables of different primitive data types and print their types using the type() function.

Python
x = 10
y = 10.5
is_active = True
name = "Alex"

print(type(x))
print(type(y))
print(type(is_active))
print(type(name))

Output
<class 'int'>
<class 'float'>
<class 'bool'>
<class 'str'>

Explanation: variables x, y, is_active, and name store values of type int, float, bool, and str, respectively. The type() function returns the data type of each variable.

Non-Primitive Data Types

Non-primitive data types are used to store multiple values or collections of data. Most non-primitive data types are mutable, which means their contents can be modified after they are created. However, some types, such as tuples, are immutable. Commonly used non-primitive data types are:

  • list: Stores an ordered collection of items.
  • tuple: Stores an ordered collection of items that cannot be modified.
  • dict: Stores data as key-value pairs.
  • set: Stores an unordered collection of unique items.

Example: Here, we create variables of different non-primitive data types and print their types using the type() function.

Python
numbers = [1, 2, 3, 4]
coordinates = (10.0, 20.0)
person = {"name": "Emma", "age": 30}
unique_numbers = {1, 2, 3, 4}

print(type(numbers))
print(type(coordinates))
print(type(person))
print(type(unique_numbers))     

Output
<class 'list'>
<class 'tuple'>
<class 'dict'>
<class 'set'>

Explanation: variables numbers, coordinates, person, and unique_numbers store values of type list, tuple, dict, and set, respectively. The type() function returns the data type of each variable.

The table below summarizes the key differences between primitive and non-primitive data types:

FeaturePrimitive Data TypesNon-Primitive Data Types
StoresA single valueMultiple values or structured data
MutabilityImmutableMostly mutable (tuple is immutable)
Examplesint, float, bool, strlist, tuple, dict, set
Memory UsageGenerally uses less memoryGenerally uses more memory
MethodsFewer built-in methodsProvides many built-in methods
CopyingAssignment typically refers to immutable valuesSupports shallow and deep copying (where applicable)
Best Used ForNumbers, text, Boolean values, and simple calculationsCollections of data, grouped values, and complex data structures
Comment