What Is Primitive Data Structure in Python?


Angela Bailey

Primitive data structures in Python are the basic building blocks that are used to store and manipulate data. These data structures are called ‘primitive’ because they are fundamental and cannot be broken down into simpler components. They are predefined by the programming language and are used to represent simple values.

Types of Primitive Data Structures in Python

Python provides several primitive data structures, including:

  • Integer: An integer is a whole number without any decimal point. It can be positive or negative.
  • Float: A float is a number that contains a decimal point. It can also be positive or negative.
  • Boolean: A boolean represents one of two states: True or False.
  • String: A string is a sequence of characters enclosed in single quotes (”) or double quotes (“”).

Working with Primitive Data Structures


An integer can be assigned to a variable like this:

# Example:
my_integer = 10

This will output:



A float can be assigned to a variable similarly:

# Example:
my_float = 3.14

The output will be:



A boolean value can only be either True or False. It can also be assigned to a variable like this:

# Example:
my_boolean = True


Strings are used to represent text in Python. They can be assigned to variables as well:

# Example:
my_string = "Hello, World!"
Hello, World!


Primitive data structures in Python allow us to store and manipulate simple values like integers, floats, booleans, and strings. Understanding these data structures is essential for working with more complex data in Python.

By using the appropriate primitive data structure based on the type of value we want to store or manipulate, we can efficiently write Python programs that handle different types of data.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy