Python Data Types Overview

Python has different data types for different kinds of values.

This beginner-friendly overview explains what data types are, why they matter, and how to recognize the most common built-in types. You do not need to memorize everything at once. The goal is to understand the basic idea and know which types you will use most often.

Quick way to check a type

Use type() to quickly check what kind of value you are working with.

x = 10
print(type(x))

y = "hello"
print(type(y))

z = [1, 2, 3]
print(type(z))

Expected output:

<class 'int'>
<class 'str'>
<class 'list'>

This is a useful first step when a program is not behaving the way you expect.

What this page covers

  • Explain what a data type is
  • Show the main built-in Python data types beginners use first
  • Help you choose the right type for simple tasks
  • Keep details light and point you to focused pages for each type

What a data type means

A data type tells Python what kind of value something is.

For example:

  • 10 is a number
  • "hello" is text
  • [1, 2, 3] is a collection of values

The type matters because it affects what you can do with the value.

  • You can add numbers
  • You can join strings
  • You can store many items in a list

Using the right type helps you write correct code and avoid common errors.

Why data types matter

Different types behave differently.

For example, this works because both values are numbers:

print(2 + 3)

Output:

5

But this does something different because both values are strings:

print("2" + "3")

Output:

23

And this causes an error because Python does not automatically combine a string and an integer in this way:

print("2" + 3)

This raises a TypeError.

Knowing the type of a value helps you:

  • understand what operations are allowed
  • use functions correctly
  • debug problems faster

If you are new to variables, see Python variables explained for beginners.

Main simple data types

These are the first built-in types most beginners use.

int

An int is a whole number.

Examples:

  • 1
  • 20
  • -5
age = 25
count = 10

print(age)
print(type(count))

float

A float is a number with a decimal point.

Examples:

  • 3.14
  • 0.5
  • -2.75
price = 19.99
temperature = -0.5

print(price)
print(type(temperature))

For a focused guide, read Python numbers explained: int and float.

str

A str is a text value.

Strings go inside quotes:

  • "hello"
  • 'Python'
  • "123"
name = "Ava"
message = "Hello"

print(name)
print(type(message))

Even if a string looks like a number, it is still text:

value = "123"
print(type(value))

To learn more, see Python strings explained: basics and examples.

bool

A bool has only two possible values:

  • True
  • False

Booleans are often used in comparisons and conditions.

is_logged_in = True
is_admin = False

print(is_logged_in)
print(type(is_admin))

For more detail, see Python booleans explained: True and False.

Main collection data types

Collection types store multiple values.

list

A list is an ordered, changeable collection.

numbers = [1, 2, 3]
numbers.append(4)

print(numbers)

Output:

[1, 2, 3, 4]

Lists are useful when:

  • order matters
  • you want to add, remove, or change items

See Python lists explained for beginners.

tuple

A tuple is ordered, but it is not usually changed after creation.

point = (10, 20)
print(point)
print(type(point))

Use tuples when you want a fixed group of values.

set

A set is an unordered collection of unique values.

items = {1, 2, 2, 3}
print(items)

Possible output:

{1, 2, 3}

Sets are useful when duplicates should be removed.

dict

A dict stores key-value pairs.

student = {
    "name": "Mia",
    "age": 14
}

print(student["name"])

Output:

Mia

Dictionaries are useful when you want to look up values by a name or key. See Python dictionaries explained.

How to check a value's type

Use type(value) to inspect a value.

print(type(10))
print(type(3.14))
print(type("hello"))
print(type([1, 2, 3]))

This is especially useful when:

  • input data is unclear
  • you are reading data from a file
  • an error suggests the wrong type is being used

You can also use isinstance() when you want to check whether a value is a specific type:

value = "hello"

print(isinstance(value, str))
print(isinstance(value, int))

Output:

True
False

For more detail, see Python type() function explained.

Choosing the right type

Use these simple rules as a starting point:

  • Use int for counting and whole-number values
  • Use float for decimal values
  • Use str for names, messages, and text input
  • Use list for ordered groups you need to change
  • Use dict when values should be looked up by key
  • Use set when you want unique values only

Examples:

count = 5                  # int
price = 8.99               # float
username = "sam"           # str
scores = [80, 90, 75]      # list
user = {"name": "Sam"}     # dict
tags = {"python", "code"}  # set

If you are unsure, ask:

  • Is this a number or text?
  • Do I need one value or many values?
  • Does order matter?
  • Do I need to change it later?
  • Do I need names for each value?

Type conversion basics

Python can convert values from one type to another with functions such as:

  • int()
  • float()
  • str()

Example:

text_number = "42"

number = int(text_number)

print(number)
print(type(number))

Output:

42
<class 'int'>

This is very common when working with user input, because input() returns a string by default.

age_text = input("Enter your age: ")
age = int(age_text)

print(age + 1)

Be careful: not every string can be converted to a number.

value = "hello"
number = int(value)

This raises a ValueError.

If you want to practice this next, read type conversion in Python or how to convert string to int in Python.

Common beginner confusion

Here are some common things that confuse new Python learners.

  • Numbers in quotes are strings, not int or float
  • input() returns a string by default
  • True and False are booleans, not strings
  • Lists, tuples, sets, and dictionaries all store groups of values, but they behave differently

Example:

a = "5"
b = 5

print(type(a))
print(type(b))

Output:

<class 'str'>
<class 'int'>

Common mistakes

These problems often happen when learning data types:

  • Treating user input as a number without converting it
  • Putting numbers in quotes and expecting math to work
  • Using the wrong collection type for the task
  • Confusing list, tuple, set, and dictionary behavior
  • Trying to combine values of different types directly

Helpful debugging steps:

print(type(value))
print(value)
print(repr(value))
print(isinstance(value, int))
print(isinstance(value, str))

What these do:

  • print(type(value)) shows the type
  • print(value) shows the normal output
  • print(repr(value)) shows a more exact representation, which is useful for spotting quotes and special characters
  • isinstance(value, int) checks whether the value is an integer
  • isinstance(value, str) checks whether the value is a string

If you run into conversion problems, these pages may help:

Good next steps

After this overview, the best next step is to learn one type at a time.

A good order is:

  1. Strings
  2. Numbers
  3. Lists
  4. Type conversion

That gives you the basics needed for most beginner Python programs.

FAQ

What is a data type in Python?

A data type is the kind of value a variable holds, such as a number, string, list, or dictionary.

How do I check a data type in Python?

Use the type() function, such as type(10) or type("hello").

What are the main Python data types for beginners?

The most important ones are int, float, str, bool, list, tuple, set, and dict.

Is input() a number in Python?

No. input() returns a string unless you convert it with int() or float().

What is the difference between list and tuple?

A list can be changed after creation. A tuple cannot be changed in the usual way.

See also