Tutorial Python Developer Tools Cheat Sheet

Free Python Built-in Functions Cheat Sheet Online — Interactive Reference with Examples

· 14 min read

Python ships with more than seventy built-in functions that are available in every module without a single import statement. They handle type conversion, mathematics, collections, input and output, object introspection, and functional programming patterns. Even experienced Python developers cannot keep all of them in working memory, and that is perfectly normal. What matters is knowing which function exists and when to reach for it. Our free interactive Python built-in functions cheat sheet solves this exact problem. It organizes every built-in into searchable categories, provides concise explanations, shows runnable code examples, and lets you copy any snippet to your clipboard with one click. Everything runs in your browser, so no data ever leaves your machine.

Whether you are writing your first Python script or reviewing a complex codebase, this cheat sheet removes the friction of looking up function signatures and behavior. You can search by keyword, filter by category, and find the right tool for the job in seconds. The visual design follows The Librarian's Card Catalog aesthetic — deep walnut-brown background, cream parchment cards with brass rivet accents, and category color coding that makes scanning effortless.

Why Python Built-in Functions Matter

Built-in functions are the standard library you do not have to import. They are implemented in optimized C, so they are typically faster than equivalent pure-Python solutions. More importantly, they represent the Pythonic way to solve common problems. Reaching for the right built-in often produces cleaner, more readable code than writing a custom loop or importing a third-party library.

Consider a common task: finding the maximum value in a list of dictionaries by a specific key. A beginner might write a loop with a tracking variable. A Pythonic developer uses max() with the key parameter. The built-in solution is shorter, faster, and immediately recognizable to anyone reading the code.

The cognitive benefit is equally important. Developers cannot memorize every signature and edge case of seventy-plus functions. A well-organized cheat sheet offloads that memory to an external reference, freeing mental capacity for problem-solving. The goal is not to memorize every built-in. It is to know that a solution exists and where to find it quickly.

Type Conversion Functions

Type conversion is one of the most common operations in Python. Whether you are parsing user input, deserializing JSON, or normalizing data from an external API, you will constantly move values between types. Python provides built-in functions for every common conversion.

Numeric Conversions

The int() function converts a value to an integer. It accepts strings, floats, and other numeric types. An optional second argument specifies the base for string inputs.

int("42")        # 42
int(3.14)        # 3
int("1010", 2)   # 10 (binary to decimal)
int("FF", 16)    # 255 (hex to decimal)

The float() function converts a value to a floating-point number. It handles strings, integers, and numeric objects.

float("3.14")    # 3.14
float(42)        # 42.0
float("inf")     # inf

The complex() function creates a complex number from real and optional imaginary parts.

complex(3, 4)    # (3+4j)
complex("3+4j")  # (3+4j)

The bool() function converts a value to a Boolean. Most values are truthy, with a small set of falsy values.

bool(1)          # True
bool(0)          # False
bool("")         # False
bool("hello")    # True
bool([])         # False
bool([1, 2])     # True

Container Conversions

The list(), tuple(), dict(), set(), and frozenset() functions create or convert values to the corresponding container types.

list("abc")      # ['a', 'b', 'c']
tuple([1, 2, 3]) # (1, 2, 3)
dict([("a", 1), ("b", 2)])  # {'a': 1, 'b': 2}
set([1, 2, 2, 3]) # {1, 2, 3}
frozenset([1, 2]) # frozenset({1, 2})

Note that dict() can also accept keyword arguments for simple cases:

dict(a=1, b=2)   # {'a': 1, 'b': 2}

Binary Data Conversions

The bytes() and bytearray() functions create immutable and mutable sequences of bytes, respectively. The memoryview() function creates a view into an existing bytes-like object without copying data.

bytes("hello", "utf-8")  # b'hello'
bytearray(b"hello")        # bytearray(b'hello')

# memoryview allows zero-copy slicing
data = bytearray(b"abcdef")
mv = memoryview(data)
sub = mv[2:5]     # memoryview without copying
data[3] = 88      # sub reflects the change

Character and Base Conversions

The chr() and ord() functions convert between Unicode code points and characters.

chr(65)          # 'A'
chr(8364)        # '€'
ord('A')         # 65
ord('€')         # 8364

The hex(), oct(), and bin() functions convert integers to string representations in base 16, 8, and 2.

hex(255)         # '0xff'
oct(8)           # '0o10'
bin(5)           # '0b101'

String Representation Functions

The ascii(), repr(), and format() functions produce string representations of objects with different purposes.

ascii("café")    # "café" (escape non-ASCII)
repr([1, 2, 3])  # '[1, 2, 3]' (unambiguous, often valid Python)
format(3.14159, ".2f")  # '3.14'

The str() function creates a human-readable string representation, which may be less precise than repr().

str(3.14159)     # '3.14159'
str([1, 2, 3])   # '[1, 2, 3]'

Math and Numeric Functions

Python provides a solid set of built-in functions for common mathematical operations. For advanced math, the math module extends these capabilities, but the built-ins handle the majority of daily needs.

Basic Arithmetic

The abs() function returns the absolute value of a number. It works with integers, floats, and complex numbers.

abs(-42)         # 42
abs(-3.14)       # 3.14
abs(3 + 4j)      # 5.0

The divmod() function returns a tuple of quotient and remainder, equivalent to (a // b, a % b) but more efficient.

divmod(17, 5)    # (3, 2)
divmod(17.5, 2.5) # (7.0, 0.0)

The pow() function raises a number to a power. It supports modular exponentiation with a third argument, which is dramatically more efficient for large numbers.

pow(2, 10)       # 1024
pow(2, 10, 100)  # 24 (2^10 mod 100, computed efficiently)

The round() function rounds a number to a given precision. The behavior with ties (exactly halfway between two values) changed in Python 3 to use banker's rounding.

round(3.14159, 2)   # 3.14
round(2.5)          # 2 (banker's rounding)
round(3.5)          # 4

The sum() function adds the items of an iterable. An optional start value provides an initial accumulator.

sum([1, 2, 3, 4])   # 10
sum([1, 2, 3], 10)  # 16
sum([])             # 0

Min and Max with Key Functions

The min() and max() functions find the smallest and largest items in an iterable. The key parameter transforms each item before comparison, enabling powerful patterns.

max([3, 1, 4, 1, 5])           # 5

words = ["apple", "banana", "cherry"]
max(words, key=len)             # "banana"

users = [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]
min(users, key=lambda u: u["age"])  # {"name": "Bob", "age": 25}

String and Text Functions

While Python strings are rich objects with dozens of methods, several built-in functions operate on strings or produce them. Understanding the distinction between str(), repr(), and ascii() is particularly important for debugging and serialization.

The str() function is for creating human-readable output. The repr() function aims to produce an unambiguous string that could often be passed to eval() to recreate the object. The ascii() function is like repr() but escapes non-ASCII characters.

name = "José"
str(name)        # 'José'
repr(name)       # "'José'"
ascii(name)      # "'Jos\xe9'"

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __repr__(self):
        return f"Point({self.x}, {self.y})"
    def __str__(self):
        return f"({self.x}, {self.y})"

p = Point(3, 4)
str(p)           # '(3, 4)'
repr(p)          # 'Point(3, 4)'

The format() function and the related format() method on strings provide powerful formatting capabilities. The built-in format() calls an object's __format__ method.

format(3.14159, ".2f")        # '3.14'
format(255, "x")               # 'ff'
format(1234567, ",")           # '1,234,567'

The bytes() and bytearray() functions are also essential for text processing when working with encoded data.

text = "Hello, 世界"
encoded = text.encode("utf-8")  # b'Hello, 世界'
decoded = bytes(encoded).decode("utf-8")  # 'Hello, 世界'

Collection and Sequence Functions

Working with collections is where Python's built-in functions truly shine. They provide elegant, efficient ways to iterate, transform, and inspect sequences without writing verbose loops.

Length, Range, and Enumeration

The len() function returns the number of items in a container. It works with strings, lists, tuples, dictionaries, sets, and any object implementing __len__.

len("hello")     # 5
len([1, 2, 3])   # 3
len({"a": 1, "b": 2})  # 2

The range() function generates a sequence of numbers. In Python 3, it returns a lazy range object rather than a list, making it memory-efficient for large sequences.

list(range(5))          # [0, 1, 2, 3, 4]
list(range(2, 10, 2))   # [2, 4, 6, 8]

# Memory efficient: range(10_000_000) uses almost no memory
for i in range(100):
    print(i)

The enumerate() function adds a counter to an iterable, returning tuples of (index, value). An optional start parameter changes the initial counter value.

fruits = ["apple", "banana", "cherry"]
for i, fruit in enumerate(fruits):
    print(f"{i}: {fruit}")
# 0: apple
# 1: banana
# 2: cherry

for i, fruit in enumerate(fruits, start=1):
    print(f"{i}: {fruit}")
# 1: apple
# 2: banana
# 3: cherry

Zipping and Unzipping

The zip() function aggregates elements from multiple iterables into tuples. It stops at the shortest iterable by default.

names = ["Alice", "Bob", "Charlie"]
ages = [30, 25, 35]
for name, age in zip(names, ages):
    print(f"{name} is {age}")

# zip with different lengths
list(zip([1, 2], ["a", "b", "c"]))  # [(1, 'a'), (2, 'b')]

The zip() function can also unzip data when combined with the unpacking operator:

pairs = [("Alice", 30), ("Bob", 25), ("Charlie", 35)]
names, ages = zip(*pairs)
# names = ('Alice', 'Bob', 'Charlie')
# ages = (30, 25, 35)

Mapping and Filtering

The map() function applies a function to every item in an iterable. The filter() function selects items for which a function returns a truthy value.

numbers = [1, 2, 3, 4, 5]

# Square every number
squares = list(map(lambda x: x**2, numbers))  # [1, 4, 9, 16, 25]

# Keep only even numbers
evens = list(filter(lambda x: x % 2 == 0, numbers))  # [2, 4]

# Often, list comprehensions are preferred in Python
squares = [x**2 for x in numbers]  # More Pythonic
evens = [x for x in numbers if x % 2 == 0]

Sorting and Reversing

The sorted() function returns a new sorted list from an iterable. The reversed() function returns a reverse iterator.

sorted([3, 1, 4, 1, 5])        # [1, 1, 3, 4, 5]
sorted(["banana", "pie", "Washington"], key=len)  # ['pie', 'banana', 'Washington']

# Sort by multiple criteria
students = [("Alice", "B", 85), ("Bob", "A", 92), ("Charlie", "B", 90)]
sorted(students, key=lambda s: (s[1], -s[2]))  # Sort by grade desc, then score asc

list(reversed([1, 2, 3]))      # [3, 2, 1]

Iteration Helpers

The iter() and next() functions work with iterators directly. iter() returns an iterator from an iterable, and next() retrieves the next item, with an optional default value.

it = iter([1, 2, 3])
next(it)         # 1
next(it)         # 2
next(it)         # 3
next(it, "done") # "done" (no StopIteration)

The slice() function creates a slice object, which is useful for programmatic slicing or implementing custom sequence types.

items = ["a", "b", "c", "d", "e"]
s = slice(1, 4, 2)
items[s]         # ['b', 'd']

I/O Functions

Input and output are fundamental to almost every program. Python's built-in I/O functions handle printing to the console, reading user input, and working with files.

Printing Output

The print() function outputs text to the standard output stream. It accepts multiple arguments, a separator, an ending string, and optional file and flush parameters.

print("Hello", "World")        # Hello World
print("a", "b", "c", sep="-")  # a-b-c
print("Loading", end="")        # No newline after
print("...done")                # Continues on same line

# Print to a file
with open("output.txt", "w") as f:
    print("Hello, file!", file=f)

# Force flush (useful for progress indicators)
import time
for i in range(5):
    print(f"\rProgress: {i+1}/5", end="", flush=True)
    time.sleep(0.5)

Reading Input

The input() function reads a line from standard input and returns it as a string. An optional prompt is displayed to the user.

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

# Reading multiple values
x, y = input("Enter two numbers: ").split()
x, y = int(x), int(y)

File Handling

The open() function opens a file and returns a file object. It is almost always used with a context manager (with statement) to ensure the file is properly closed.

# Reading a file
with open("data.txt", "r", encoding="utf-8") as f:
    content = f.read()

# Reading line by line
with open("data.txt", "r") as f:
    for line in f:
        print(line.strip())

# Writing to a file
with open("output.txt", "w") as f:
    f.write("Hello, World!\n")

# Appending to a file
with open("log.txt", "a") as f:
    f.write("New log entry\n")

# Common modes: r (read), w (write), a (append), x (exclusive creation)
# With + for read+write: r+, w+, a+
# Binary modes: rb, wb, ab

Object and Class Functions

Python's dynamic nature means you often need to inspect, create, or manipulate objects and classes at runtime. The built-in functions in this category are essential for metaprogramming, debugging, and building flexible APIs.

Type Checking

The isinstance() function checks if an object is an instance of a class or tuple of classes. It is preferred over type() for type checking because it respects inheritance.

isinstance(42, int)            # True
isinstance("hello", (str, bytes))  # True
isinstance([], list)            # True
isinstance([], (list, tuple))   # True

class Animal: pass
class Dog(Animal): pass
d = Dog()
isinstance(d, Dog)     # True
isinstance(d, Animal)  # True (inheritance)
type(d) == Animal      # False (does not respect inheritance)

The issubclass() function checks if a class is a subclass of another.

issubclass(Dog, Animal)   # True
issubclass(bool, int)     # True

The type() function returns the type of an object. With three arguments, it creates a new class dynamically.

type(42)           # <class 'int'>
type("hello")      # <class 'str'>

# Dynamic class creation
MyClass = type("MyClass", (), {"x": 10})
obj = MyClass()
obj.x              # 10

Attribute Access

The getattr(), setattr(), delattr(), and hasattr() functions provide programmatic access to object attributes.

class Person:
    def __init__(self, name):
        self.name = name

p = Person("Alice")
getattr(p, "name")           # "Alice"
getattr(p, "age", 30)        # 30 (default if missing)

setattr(p, "age", 25)
p.age                        # 25

hasattr(p, "name")           # True
hasattr(p, "salary")         # False

delattr(p, "age")
hasattr(p, "age")            # False

Callable and Object Creation

The callable() function checks if an object can be called like a function.

callable(print)        # True
callable(len)          # True
callable(42)           # False

def greet(): pass
callable(greet)        # True

The object() function returns a new featureless object. It is the base class for all classes and is occasionally useful as a sentinel value.

sentinel = object()   # Unique object, useful as a default

def find(items, target, default=sentinel):
    for item in items:
        if item == target:
            return item
    if default is sentinel:
        raise ValueError("Not found")
    return default

Class Utilities

The property(), classmethod(), staticmethod(), and super() functions are used when defining classes. While they are typically used as decorators, understanding their function form is valuable.

class Temperature:
    def __init__(self, celsius):
        self._celsius = celsius

    def get_fahrenheit(self):
        return self._celsius * 9/5 + 32

    def set_fahrenheit(self, value):
        self._celsius = (value - 32) * 5/9

    fahrenheit = property(get_fahrenheit, set_fahrenheit)

t = Temperature(0)
t.fahrenheit           # 32.0
t.fahrenheit = 212
t._celsius             # 100.0

Functional Programming Helpers

Python supports functional programming patterns through several built-in functions. While list comprehensions and generator expressions are often preferred for readability, map(), filter(), and related functions remain valuable, especially when combined or used with existing functions.

Map, Filter, and Zip

These functions were covered in the Collections section, but they are worth revisiting from a functional programming perspective. They can be combined to create powerful data pipelines.

# Extract and transform data in one pipeline
users = [
    {"name": "Alice", "age": 30, "active": True},
    {"name": "Bob", "age": 17, "active": True},
    {"name": "Charlie", "age": 25, "active": False},
]

# Get names of active adults
active_adults = map(
    lambda u: u["name"],
    filter(lambda u: u["active"] and u["age"] >= 18, users)
)
list(active_adults)  # ['Alice']

# Equivalent list comprehension
[u["name"] for u in users if u["active"] and u["age"] >= 18]

Any and All

The any() and all() functions test whether any or all items in an iterable are truthy. They short-circuit, stopping as soon as the result is determined.

any([False, False, True])   # True
all([True, True, True])     # True
all([True, False, True])    # False

# Practical examples
numbers = [2, 4, 6, 8]
all(n % 2 == 0 for n in numbers)  # True (all even)

# Check if any user is admin
users = [{"role": "user"}, {"role": "admin"}, {"role": "user"}]
any(u["role"] == "admin" for u in users)  # True

Lambda Expressions

While not a built-in function, lambda expressions are essential for functional programming in Python. They create small anonymous functions.

# Simple lambda
square = lambda x: x**2
square(5)   # 25

# Lambda with map
list(map(lambda x: x.upper(), ["a", "b", "c"]))  # ['A', 'B', 'C']

# Lambda with sorted
students = [("Alice", 85), ("Bob", 92), ("Charlie", 78)]
sorted(students, key=lambda s: s[1], reverse=True)  # By score desc

For reductions that accumulate a result, the functools.reduce function from the standard library is useful:

from functools import reduce

# Product of all numbers
reduce(lambda a, b: a * b, [1, 2, 3, 4, 5])  # 120

# Flatten a list of lists
reduce(lambda a, b: a + b, [[1, 2], [3, 4], [5, 6]])  # [1, 2, 3, 4, 5, 6]

Introspection and Debugging Functions

Introspection is the ability to examine the type and properties of objects at runtime. Python's built-in introspection functions are invaluable for debugging, exploring unfamiliar APIs, and building dynamic tools.

Inspecting Objects

The dir() function returns a list of valid attributes for an object. Without arguments, it returns names in the current local scope.

dir(str)         # All string methods

class Person:
    def __init__(self, name):
        self.name = name
    def greet(self):
        return f"Hello, {self.name}"

p = Person("Alice")
dir(p)           # ['__class__', ..., 'greet', 'name']

# Filter out dunder methods
[n for n in dir(p) if not n.startswith("_")]  # ['greet', 'name']

The vars() function returns the __dict__ attribute of an object, which stores its writable attributes.

vars(p)          # {'name': 'Alice'}

# Without arguments, same as locals()
def demo():
    x = 10
    y = 20
    print(vars())  # {'x': 10, 'y': 20}
demo()

Namespace Inspection

The locals() and globals() functions return dictionaries representing the current local and global symbol tables.

x = 10

def func():
    y = 20
    print(locals())   # {'y': 20}
    print(globals()["x"])  # 10

func()

Help and Documentation

The help() function invokes the built-in help system. It is particularly useful in interactive sessions.

help(str.upper)   # Shows docstring for str.upper
help(len)         # Shows docstring for len

Identity and Hashing

The id() function returns the unique identifier of an object, which corresponds to its memory address in CPython.

a = [1, 2, 3]
b = a
c = [1, 2, 3]

id(a) == id(b)   # True (same object)
id(a) == id(c)   # False (different objects with same value)

The hash() function returns the hash value of an object, used by dictionaries and sets for key lookup.

hash("hello")    # Some integer
hash(42)         # 42
hash((1, 2))     # Hash of tuple

# Mutable objects are unhashable
hash([1, 2])     # TypeError: unhashable type: 'list'

Interactive Debugging

The breakpoint() function drops into the debugger at the call site. By default, it uses pdb, but the PYTHONBREAKPOINT environment variable can change this behavior.

def calculate(x, y):
    result = x + y
    breakpoint()   # Drops into pdb
    return result * 2

# In pdb: you can inspect variables, step through code
# (Pdb) p result
# (Pdb) c   # continue
# (Pdb) q   # quit

Global and System Functions

These functions interact with Python's import system, compilation, and execution environment. They are powerful but should be used with caution, especially eval() and exec().

Dynamic Import

The __import__() function is called by the import statement. It is rarely needed directly but is useful for dynamic imports.

# Dynamic import by string name
math = __import__("math")
math.sqrt(16)    # 4.0

# The importlib module provides a cleaner API
import importlib
math = importlib.import_module("math")

Compilation and Execution

The compile() function compiles source code into a code object that can be executed by exec() or eval().

code = compile("x + y", "<string>", "eval")
exec(compile("x = 10", "<string>", "exec"))
eval(code, {"x": 5, "y": 3})  # 8

The eval() function evaluates a string as a Python expression. The exec() function executes arbitrary Python code. Both are powerful and dangerous when used with untrusted input.

# Safe usage with controlled input
x = 10
result = eval("x * 2")  # 20

# NEVER do this with user input
user_input = "__import__('os').system('rm -rf /')"
# eval(user_input)  # DANGEROUS!

# Safer alternative: ast.literal_eval
import ast
ast.literal_eval("[1, 2, 3]")  # [1, 2, 3]
# ast.literal_eval("__import__('os')")  # ValueError

Interactive Shell Helpers

The exit() and quit() functions are provided by the site module for interactive use. They raise a SystemExit exception.

# In interactive Python shell
exit()   # Exits the interpreter
quit()   # Same as exit()

How to Use the Interactive Cheat Sheet

Our online Python built-in functions cheat sheet puts all of these functions at your fingertips. The interface is organized into category tabs, so you can narrow your view to only the functions relevant to your current task. A search bar filters functions in real time by name, description, or example content.

Each function card shows the function signature, a concise description, one or more runnable code examples, and its category tag. Click the Copy button to paste the example directly into your editor. The visual design follows The Librarian's Card Catalog aesthetic — deep walnut-brown background, cream parchment cards with brass rivet accents, and category color coding that makes scanning effortless. Numeric functions are highlighted in forest green, encoding functions in sepia, I/O functions in gold leaf, and so on.

The cheat sheet is particularly useful when you know what you want to accomplish but cannot recall the exact function name. Type a keyword like "convert" or "binary" into the search box, and the relevant functions appear instantly. Filter by category when you are working in a specific domain, such as file I/O or object introspection.

Related Tools

Frequently Asked Questions

Is this Python cheat sheet free?

Yes. The tool is completely free with no limits, no registration, and no advertisements.

How many built-in functions are included?

The cheat sheet covers all 70+ built-in functions available in Python 3, organized into ten searchable categories.

Can I search for functions?

Yes. The search bar filters functions in real time by name, description, or example content.

Is my data safe?

Yes. The cheat sheet is one hundred percent client-side. No code or usage data is sent to a server.

Does this replace the official Python documentation?

No. This cheat sheet is a quick reference for common built-in functions. For deep understanding of implementation details, edge cases, and C API internals, consult the official docs.python.org documentation.

What Python version is this for?

The cheat sheet covers built-in functions available in Python 3.8 and later. Some functions like breakpoint() were introduced in Python 3.7.

Conclusion

Python's built-in functions form the foundation of everyday programming in the language. From converting types and performing math to manipulating collections and inspecting objects at runtime, these 70+ functions solve the majority of common problems without requiring a single import statement. Memorizing all of them is neither necessary nor efficient. What matters is knowing the landscape and having a fast way to find the right tool when you need it.

Our free interactive Python built-in functions cheat sheet removes the friction from that lookup process. With every function organized into searchable categories, runnable code examples for every entry, and one-click copying, it is the fastest way to find the Python built-in you need without breaking your flow. Bookmark it, share it with your team, and keep shipping Python code.

Found this useful? Check out our free developer tools or browse more articles.