Understanding data types in Python 3 is one of the most important foundational skills in Python programming — every value in Python belongs to a specific data type, and knowing data types in Python 3 determines what operations you can perform, how memory is used, and how your code behaves.
In this up-to-date 2025–2026 guide, you’ll learn exactly how data types in Python 3 work: integers, floats, booleans, strings, lists, tuples, dictionaries, sets, NoneType, type checking/conversions, common pitfalls, and when to use each type. All examples are tested on Python 3.10–3.13.
Key Takeaways – Data Types in Python 3
- Data types in Python 3 are dynamic — no need to declare types (Python infers them automatically).
- Core built-in types: int, float, bool, str, list, tuple, dict, set, NoneType.
- Mutable types (list, dict, set) can change after creation; immutable (int, float, bool, str, tuple) cannot.
- Use type() to check a value’s type, isinstance() to test safely.
- Type conversion: int(), float(), str(), list(), etc. — very common in real code.
- Strings are immutable sequences — powerful slicing, formatting (f-strings), methods.
- Lists are mutable, ordered; tuples are immutable, ordered; sets are mutable, unordered, unique.
- Dictionaries are mutable, ordered (since 3.7), key-value mappings — backbone of modern Python.
Prerequisites
- Python 3.8+ installed
- Basic Python knowledge (variables, print, loops)
- Text editor or IDE (VS Code recommended)
1. Numbers – Integers (int) & Floating-Point (float)
Integers (whole numbers — positive, negative, zero):
age = 30
temperature = -5
big_number = 1_000_000_000 # underscores ignored (Python 3.6+)
print(type(age)) #
Floats (decimal numbers):
price = 19.99
pi = 3.1415926535
scientific = 1.23e-4 # 0.000123
print(type(price)) #
Math works naturally:
result = 10 / 3 # 3.3333333333333335 (true division)
integer_div = 10 // 3 # 3 (floor division)
power = 2 ** 10 # 1024
2. Booleans (bool) – True & False
Used for conditions, logic:
is_adult = age >= 18 # True
has_access = True
print(type(is_adult)) #
3. Strings (str) – Text Data
Immutable sequences of characters:
name = "Zain"
greeting = 'Hello'
multiline = """Line 1
Line 2"""
print(type(name)) #
Powerful features:
print(f"Hi {name}!") # f-strings (Python 3.6+)
print(name.upper()) # ZAIN
print("Python" in "I love Python") # True
print(name[0:2]) # Za (slicing)
4. Lists – Mutable, Ordered Sequences
Most flexible collection:
fruits = ["apple", "banana", "cherry"]
numbers = [1, 2, 3, 4]
mixed = [1, "two", 3.0, True]
print(type(fruits)) #
Operations:
fruits.append("date") # add item
fruits.pop() # remove last
print(fruits[1]) # banana
fruits[0] = "avocado" # mutable
5. Tuples – Immutable, Ordered Sequences
Like lists, but cannot change:
coordinates = (10.5, 20.8)
person = ("Zain", 30, "Karachi")
print(type(coordinates)) #
Use when data should never change:
# coordinates[0] = 99 # TypeError – immutable
6. Dictionaries (dict) – Key-Value Mappings
Ordered (since 3.7), mutable:
user = {
"name": "Zain",
"age": 30,
"city": "Karachi"
}
print(type(user)) #
Access & modify:
print(user["name"]) # Zain
user["job"] = "Developer" # add key
del user["age"] # remove
7. Sets – Mutable, Unordered, Unique
No duplicates, fast membership testing:
unique_numbers = {1, 2, 2, 3} # {1, 2, 3}
print(type(unique_numbers)) #
Operations:
unique_numbers.add(4)
print(2 in unique_numbers) # True
8. NoneType – The Absence of Value
Special type representing “nothing”:
result = None
print(type(result)) #
Common in functions that don’t return anything.
Type Checking & Conversion
x = 42
print(type(x)) #
print(isinstance(x, int)) # True
# Conversions
str(42) # "42"
int("100") # 100
float("3.14") # 3.14
list("abc") # ['a', 'b', 'c']
Common Pitfalls with Data Types in Python 3
- Floating-point precision: 0.1 + 0.2 != 0.3 (use decimal module for money).
- Mutable defaults in functions: avoid def func(lst=[]): — creates shared list.
- String vs bytes confusion in Python 3 (strict separation).
- Dictionary key mutability: only immutable types (int, str, tuple) can be keys.
How to Work with Data Types in Python 3 – FAQ (2025–2026)
- What are the main data types in Python 3?
int, float, bool, str, list, tuple, dict, set, NoneType — core data types in Python 3. - Are data types in Python 3 mutable or immutable?
Mutable: list, dict, set; Immutable: int, float, bool, str, tuple. - How do I check a data type in Python 3?
Use type(x) or isinstance(x, int) — best way to inspect data types in Python 3. - Can I change a tuple in Python 3?
No — tuples are immutable, unlike lists. - What is None in Python 3?
Special value meaning “no value” — common return for functions without output.
Summary
You now have a complete understanding of data types in Python 3: how integers, floats, booleans, strings, lists, tuples, dictionaries, sets, and None work, how to check/convert them, and best practices for real-world code.
Mastering data types in Python 3 is the foundation for writing clean, efficient, bug-resistant programs — whether you’re building web apps, data science pipelines, automation scripts, or AI projects.
Recommended Next Tutorials
- Python Variables & Type Hints (2025–2026)
- Python Lists vs Tuples vs Sets – When to Use Each
- Python Dictionaries – Advanced Patterns
- Python Type Checking with mypy
- Build a Small Project Using All Data Types