---
title: Data Types in Python
source: https://app.sythra.ai/learn/python/data-types
topic: Python
updated: 2026-08-12
publisher: Sythra (https://app.sythra.ai)
---

# Data Types in Python

Python's built-in data types include int, float, str, and bool (primitive — single values) and list, tuple, set, and dict (non-primitive — collections). Some are mutable (list, dict, set); others are immutable (int, float, str, tuple, bool).

_Source: [https://app.sythra.ai/learn/python/data-types](https://app.sythra.ai/learn/python/data-types) — free to read on Sythra._

## Key points

- int, float, bool, str are primitive — single atomic values
- list, tuple, set, dict are non-primitive — hold multiple values
- Immutable: int, float, bool, str, tuple — cannot change after creation
- Mutable: list, dict, set — can change in place
- type() always tells you exactly what you are holding
- Choosing the right type prevents entire classes of bugs

Want to understand **data types in Python**? Every value you hand Python gets _classified_ the instant you create it — a number does not sit on the same shelf as a word, and a list does not live where single values live. Those shelves are Python's data types.

This page covers the built-in types you will meet constantly — `int`, `float`, `str`, `bool`, `list`, `tuple`, `dict`, `set` — plus the two ideas that organize them: **primitive vs non-primitive** and **mutable vs immutable**. Pair it with [Types, Values, and Errors](/learn/python/types-values-errors) for how `type()` works, and [Variables](/learn/python/variables) for how names attach to these values.

## What you will learn

By the end you can:

- Name Python's core built-in data types and what each one is for
- Tell **primitive** types (`int`, `float`, `bool`, `str`) from **non-primitive** ones (`list`, `tuple`, `set`, `dict`)
- Explain **mutable** vs **immutable** and why it matters
- Pick the right container: list vs tuple vs set vs dict
- Use `type()` to confirm what you actually created

> We are **not** covering type casting (`int()`, `str()` conversions) or custom classes yet — those get their own pages. This is the map of what Python ships with by default.

## Why data types exist

Python needs to know three things about every value: what operations are allowed on it, how much memory to use, and how it should behave. The _same symbol_ can mean different things depending on type — `+` adds numbers but joins strings.

## Numbers: values that can be calculated

### Integers — whole and steady

```python
count = 10
temperature = -5

print(type(count))
# <class 'int'>
```

No decimals, no fractions. Python calls these **integers**.

### Floating-point numbers — numbers that slide

```python
pi = 3.14159
gravity = 9.8

print(type(pi))
# <class 'float'>
```

Numbers with decimal points are stored using floating-point representation.

## Strings: values that speak

```python
name = "ada"
print(type(name))
# <class 'str'>
```

Quotes matter — without them, Python assumes you are naming a variable. Strings can contain letters, numbers, symbols, and even spaces, but Python treats all of it as **text**, not math.

## Booleans: yes or no, nothing else

```python
is_active = True
is_logged_in = False

print(type(is_active))
# <class 'bool'>
```

Booleans have exactly two possible values. They quietly power decisions, conditions, and logic everywhere in a program.

## Lists: many things, one name

```python
marks = [85, 90, 78]
names = ["Alice", "Bob", "Charlie"]

print(type(marks))
# <class 'list'>
```

A list groups values under one name. Lists can hold multiple values, mix data types, and be changed after creation.

## Tuples: lists that don't change

```python
coordinates = (10, 20)
print(type(coordinates))
# <class 'tuple'>
```

Tuples look like lists but behave differently. Once created, a tuple **cannot be modified** — use them when safety and consistency matter.

## Dictionaries: meaning over position

```python
student = {
    "name": "Ravi",
    "age": 20,
    "branch": "CSE"
}

print(type(student))
# <class 'dict'>
```

A dictionary stores **key–value pairs**. You do not ask _where_ a value lives — you ask **what it is called**.

## Sets: uniqueness matters

```python
unique_ids = {101, 102, 103}
print(type(unique_ids))
# <class 'set'>
```

A set is a collection of **unique values** — duplicates are automatically removed. Sets are useful when presence matters more than order.

Python never forgets what type a value is, no matter how you inspect it:

```python
print(type(42))     # <class 'int'>
print(type("42"))   # <class 'str'>
print(type([42]))   # <class 'list'>
```

## Primitive vs non-primitive data types

Some values are simple. Some values are built from other values. That is the difference between **primitive** and **non-primitive** data types.

### Primitive types — the building blocks

Primitive types represent one clear, atomic idea:

- `int` — whole numbers
- `float` — decimal numbers
- `bool` — True or False
- `str` — text (internally complex, but behaves like a single value)

```python
age = 20
price = 99.99
is_student = True
name = "Aditya"
```

Each variable here refers to **one single value** — you do not logically break it into smaller meaningful parts.

### Non-primitive types — collections and structures

Non-primitive types are built from multiple values: they can store many elements, organize data, and represent more complex structures. Common ones: `list`, `tuple`, `set`, `dict`.

```python
marks = [85, 90, 78]
coordinates = (10, 20)
unique_ids = {101, 102, 103}
student = {"name": "Ravi", "age": 20}
```

| Primitive | Non-Primitive |
| --- | --- |
| Stores a single value | Stores multiple values |
| Simple data | Structured data |
| int, float, bool, str | list, tuple, set, dict |

> **Worth knowing:** 

## Mutable vs immutable — what can change

Python has two kinds of values: flexible ones, and ones fixed once created.

### Immutable (non-mutable)

Imagine carving something in stone — once written, you cannot edit it; to get something different, you carve a new stone. An **immutable** value cannot be changed after creation. Any "modification" actually creates a new object.

- `int`
- `float`
- `bool`
- `str`
- `tuple`

### Mutable

Now imagine writing with a pencil — you can erase, add, and modify the same page repeatedly. A **mutable** value can change after creation without becoming a new object.

- `list`
- `dict`
- `set`

Immutable objects protect stability. Mutable objects allow flexibility. Good programming means knowing which one a situation needs.

## Quick reference: all built-in types at a glance

| Type | Primitive? | Mutable? | Ordered? | Duplicates? | Example |
| --- | --- | --- | --- | --- | --- |
| int | Primitive | No | — | — | 10 |
| float | Primitive | No | — | — | 3.14 |
| bool | Primitive | No | — | — | True |
| str | Primitive* | No | Yes | Yes | "Hello" |
| list | Non-Primitive | Yes | Yes | Yes | [1, 2, 3] |
| tuple | Non-Primitive | No | Yes | Yes | (1, 2, 3) |
| set | Non-Primitive | Yes | No | No | {1, 2, 3} |
| dict | Non-Primitive | Yes | Yes (keys 3.7+) | Keys: No, Values: Yes | {"a": 1} |

## Common mistakes

- Forgetting quotes and accidentally naming a variable instead of writing a string
- Expecting a tuple to accept item reassignment like a list
- Assuming dict key order does not matter for equality or display
- Using a list when a set would remove needed duplicate-checking work
- Confusing `str`'s immutability with lists being similarly protected

## Why this matters

Every bug involving "wrong" behavior traces back to a type you did not expect. Knowing the shelf a value sits on — primitive or structured, mutable or fixed — is what lets you predict how your program will behave before you run it.

> **Practice with Sythra:**  [Practice with AI tutor](https://app.sythra.ai/pricing)

## FAQ

### What are the main data types in Python?

Python's core built-in types are int, float, str, and bool (primitive types holding single values), plus list, tuple, set, and dict (non-primitive types that hold collections of values).

### What is the difference between primitive and non-primitive data types in Python?

Primitive types (int, float, bool, str) store a single value. Non-primitive types (list, tuple, set, dict) are built from multiple values and organize data into structures.

### What is the difference between mutable and immutable data types in Python?

Mutable types (list, dict, set) can be changed in place after creation. Immutable types (int, float, bool, str, tuple) cannot be changed — any modification creates a new object.

### Is a string mutable or immutable in Python?

A string is immutable. Once created, its characters cannot be changed in place; operations like concatenation produce a new string object.

### What is the difference between a list and a tuple in Python?

A list is mutable — you can add, remove, or change items after creation. A tuple is immutable — once created, its contents cannot change. Both are ordered and allow duplicates.

### How do you check the data type of a value in Python?

Use the built-in type() function, for example type(42) returns  and type("42") returns .

## Related

- [Types, Values, and Errors in Python](https://app.sythra.ai/learn/python/types-values-errors) — How type() works and what values and types mean.
- [Variables in Python](https://app.sythra.ai/learn/python/variables) — Names that point at the data types on this page.
- [Operators and Operands in Python](https://app.sythra.ai/learn/python/operators-operands) — How operators behave differently across types.
- [Order of Operations in Python](https://app.sythra.ai/learn/python/order-of-operations) — Precedence rules for combining numeric types.
- [Interactive Mode vs Script Mode in Python](https://app.sythra.ai/learn/python/interactive-mode-vs-script-mode) — Why the same line of code behaves differently in each mode.
- [The input() Function in Python](https://app.sythra.ai/learn/python/python-input-function) — Reading user input and converting it from a string to a number.
- [Strings in Python](https://app.sythra.ai/learn/python/strings-in-python) — Indexing, slicing, immutability, and string methods.
- [Lists in Python](https://app.sythra.ai/learn/python/lists-in-python) — Mutability, list methods, map/filter/reduce, and the aliasing trap.
- [Dictionaries in Python](https://app.sythra.ai/learn/python/dictionaries-in-python) — Key-value pairs, the histogram pattern, and memoization.
- [Tuples in Python](https://app.sythra.ai/learn/python/tuples-in-python) — Immutability, unpacking, *args, zip(), and DSU sorting.
- [Sets in Python](https://app.sythra.ai/learn/python/sets-in-python) — Uniqueness, fast membership checks, and set math.
- [Type Casting in Python](https://app.sythra.ai/learn/python/type-casting) — Implicit vs explicit conversion between data types.
- [Functions in Python: Definition and How They Work](https://app.sythra.ai/learn/python/functions-in-python) — What functions are, def, parameters, and local scope.
- [Python course hub](https://app.sythra.ai/learn/python) — All free Python explainers and the path into Agentic practice.

---

Written by Sythra — Learn machine learning by building. Practice this topic with Sythra's AI tutor: https://app.sythra.ai/pricing
