Skip to content
C Codeloom
Python

Python Data Types: The Complete Beginner Guide

An overview of every built-in data type in Python — int, float, str, bool, list, tuple, dict, set, and None — with examples and guidance on when to use each.

·7 min read · By Yash Kesharwani
Beginner 9 min read

What you'll learn

  • Every built-in data type Python provides
  • How to recognise and create values of each type
  • The difference between mutable and immutable types
  • When to reach for each type in real code
  • How to inspect types with type() and isinstance()

Prerequisites

Every value in Python belongs to a type. The type determines what operations are valid on the value — you can add two numbers but not two booleans in a useful way, you can slice a string but not an integer. Understanding the built-in types is the foundation of every other topic in the language.

This post is the map. Each type gets a quick overview and an example here, and is covered in depth in its own dedicated post later in the series.

How Python sees types

Python is dynamically typed: the type travels with the value, not with the variable name. You can always check what type a value is using the built-in type() function:

print(type(10))         # <class 'int'>
print(type(3.14))       # <class 'float'>
print(type("hello"))    # <class 'str'>
print(type(True))       # <class 'bool'>
print(type([1, 2, 3]))  # <class 'list'>

For checking inside conditions, isinstance() is the idiomatic choice — it accepts a value and one or more types:

value = 42
if isinstance(value, int):
    print("It's an integer.")

Use isinstance() rather than type(x) == int in real code. The reasons relate to inheritance, which we will meet later.

The numeric types

int — whole numbers

The int type represents integers of any size. There is no upper limit beyond your computer’s memory.

age = 25
year = 2026
huge = 10**100        # a googol — Python handles it natively
negative = -7

float — decimal numbers

The float type represents numbers with a decimal point. It uses the standard IEEE 754 double-precision representation, the same as JavaScript, Java, and C.

price = 19.99
pi = 3.14159
scientific = 1.5e6     # 1,500,000

A subtle but important fact: floats cannot represent every decimal exactly. This is not a Python bug — it is a hardware reality:

print(0.1 + 0.2)       # 0.30000000000000004

When you need exact decimal arithmetic (e.g. money), use the decimal module. For most everyday calculations, floats are fine.

bool — true or false

A bool is either True or False. Booleans are used for conditions, flags, and the result of any comparison.

is_logged_in = True
has_admin_rights = False
print(10 > 5)          # True
print(10 == 5)         # False

bool is technically a subclass of int in Python — True is 1, False is 0. You rarely need to know that, but it explains why True + True returns 2.

The text type

str — strings

A str is a sequence of characters wrapped in single, double, or triple quotes:

name = "Alice"
greeting = 'Hello!'
paragraph = """This is
a multi-line
string."""

Strings support indexing, slicing, concatenation, and dozens of methods:

word = "Python"
print(word[0])         # P
print(word[-1])        # n
print(word.upper())    # PYTHON
print(word + " 3")     # Python 3

Strings are immutable — once created, their contents cannot change. Any method that “modifies” a string actually returns a new one.

The collection types

A collection holds multiple values inside a single object. Python provides four built-in collection types, each suited to a different access pattern.

list — ordered, mutable sequences

Use a list when you need an ordered collection that can grow, shrink, or be modified in place.

fruits = ["apple", "banana", "cherry"]
fruits.append("date")
fruits[0] = "apricot"
print(fruits)          # ['apricot', 'banana', 'cherry', 'date']

Lists are the workhorse collection in Python. Most data you receive — rows from a database, lines from a file, items from an API — arrives as a list.

tuple — ordered, immutable sequences

A tuple looks like a list but uses parentheses and cannot be modified after creation.

point = (3, 4)
print(point[0])        # 3
# point[0] = 5         # TypeError: 'tuple' object does not support item assignment

Tuples are ideal for fixed-size records and for any value that should not change accidentally — coordinates, RGB colours, the result of a function returning multiple values.

dict — key-value mappings

A dict (dictionary) stores associations between keys and values, like a real-world dictionary maps words to definitions.

user = {
    "name": "Alice",
    "age": 30,
    "is_admin": False,
}
print(user["name"])       # Alice
user["age"] = 31
user["email"] = "a@x.com"

Dictionaries are extraordinarily useful — most JSON data, most configuration, and most lookup tables map onto a dictionary cleanly.

set — unordered collections of unique values

A set stores values without duplicates. It is unordered and supports fast membership checks and mathematical set operations.

unique_tags = {"python", "tutorial", "python"}
print(unique_tags)            # {'python', 'tutorial'}
print("python" in unique_tags)   # True

Reach for a set whenever you need to deduplicate items or test “does this collection contain X?” frequently.

The “nothing” type

NoneType — the absence of a value

Python has one special value, None, used to indicate “no value here.” It is the only instance of the type NoneType.

result = None
print(result is None)   # True

Functions that perform an action without producing a result (such as list.append) return None. It is the closest equivalent to null in other languages.

The idiomatic way to test for None is value is None, not value == None.

Mutable vs immutable

Every Python type is either mutable (can be changed in place) or immutable (cannot). This distinction matters more than beginners expect, because mutable objects shared between variables can be modified through any of them.

MutableImmutable
listint, float, bool
dictstr
settuple
NoneType

A small demonstration:

# Immutable (str): reassignment creates a new object
text = "hello"
text = text + " world"
print(text)            # "hello world"

# Mutable (list): methods modify the existing object
nums = [1, 2, 3]
nums.append(4)
print(nums)            # [1, 2, 3, 4]

We’ll revisit this idea in the post on lists, where it has practical consequences.

Try it yourself. In the REPL, create one value of each type covered above. Pass each to type() and confirm the result. Then try to do something a type doesn’t support — for example, "hello" + 5 — and read the error message. Type errors are some of the clearest Python ever produces, and reading them is a skill worth practising.

Choosing the right type — a quick guide

A practical cheat sheet for when to reach for what:

  • A whole number? int
  • A measurement, ratio, or price? float (or Decimal for money)
  • A true/false flag? bool
  • Text? str
  • An ordered, growing collection? list
  • A fixed-size record that should not change? tuple
  • A key-value lookup? dict
  • A collection of unique items, or fast membership tests? set
  • “No value yet” or “explicitly nothing”? None

Most professional Python code uses these nine types for the vast majority of its data. The standard library provides specialised containers (deque, Counter, defaultdict, namedtuple, dataclass) which are essentially convenient packagings on top.

Recap

You now know:

  • Python has numeric types (int, float, bool), a text type (str), four collection types (list, tuple, dict, set), and a null type (NoneType)
  • type() and isinstance() reveal the type of any value
  • Some types are mutable (can change in place) and some are immutable (always replaced rather than modified)
  • Each type fits a particular access pattern — choosing well makes code shorter and clearer

Next steps

The next post zooms in on Python’s numbers and math — operators, precedence, the math module, and the floating-point quirks that catch every beginner at least once.

→ Next: Numbers and Math in Python

Questions or feedback? Email codeloomdevv@gmail.com.