type

In Python, a type represents the classification of a value or object, determining the kinds of operations that can be performed on it and the ways it can interact with other objects.

Types are essentially the blueprint or definition that specifies what an object is, such as an integer, string, list, or user-defined class.

Example

Here are a few examples of different types in Python. Note that you can use the built-in type() function to determine an object’s type:

Python
>>> type(42)
<class 'int'>

>>> type("Alice")
<class 'str'>

>>> type([1, 2, 3])
<class 'list'>

>>> class Circle: pass
... 
>>> type(Circle)
<class 'type'>

This code shows different Python types, including an integer (int), string (str), list, and user-defined class. To run the check, you use the type() function. Additionally, user-defined classes like Circle are themselves objects of the type class, highlighting Python’s nature where classes are first-class objects.

Tutorial

Basic Data Types in Python: A Quick Exploration

In this tutorial, you'll learn about the basic data types that are built into Python, including numbers, strings, bytes, and Booleans.

basics python

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated Jan. 20, 2025 • Reviewed by Dan Bader