Python Built-in Functions: Complete Guide

Published on: July 10, 2026
Reading time: 4 minutes
Estatísticas e análise de dados com Python

Python built-in functions are tools that are available immediately, without installing a package or importing a module. Functions such as print(), len(), type(), sum(), sorted(), and enumerate() solve common problems with concise, tested code.

This guide organizes the most useful built-ins by purpose instead of presenting an overwhelming alphabetical list. You will learn functions for input and output, types, numbers, collections, iteration, inspection, functional programming, files, and object-oriented code.

Review Python data types, functions, and loops when you need more background.

What Does Built-in Mean?

A built-in function belongs to Python’s standard execution environment. You can call it directly:

print(len("Python"))

You do not need an import statement. The official built-in functions reference lists every function and its exact behavior. The standard types documentation explains the objects these functions work with.

name = "Kai"
score = 95

print(name)
print("Score:", score)
print(f"{name} scored {score} points")

print() can receive several values, a custom separator, and a custom ending:

print("2026", "07", "10", sep="-")
print("Loading", end="...")
print("done")

input(): Read User Input

name = input("What is your name? ")
print(f"Hello, {name}!")

input() always returns a string. Convert the result when you need a number:

age = int(input("Age: "))
height = float(input("Height in meters: "))

Conversion can fail, so interactive programs should validate input with exception handling.

len(): Count Items

word = "Python"
numbers = [10, 20, 30]
user = {"name": "Lina", "active": True}

print(len(word))
print(len(numbers))
print(len(user))

For a dictionary, len() counts keys. For a string, it counts characters. For a list or tuple, it counts elements.

type() and isinstance(): Inspect Types

value = 42

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

Use isinstance() for validation because it supports inheritance and multiple accepted types:

if isinstance(value, (int, float)):
    print("The value is numeric")

Type Conversion Functions

Several built-ins create or convert values:

number = int("42")
price = float("19.95")
text = str(2026)
values = list((1, 2, 3))
coordinates = tuple([10, 20])
unique = set([1, 1, 2, 3])
record = dict(name="Ari", active=True)

Conversions do not always succeed. For example, int("hello") raises ValueError. The try and except guide explains safe conversion.

Numeric Functions

abs()

print(abs(-18))
print(abs(-3.5))

abs() returns the absolute value.

round()

price = 19.987
print(round(price, 2))

Floating-point values have representation limitations. Do not use ordinary floats for exact financial accounting without understanding those limitations.

min() and max()

temperatures = [21, 24, 19, 27]

print(min(temperatures))
print(max(temperatures))

sum()

prices = [10.5, 20.0, 7.25]
total = sum(prices)
print(total)

pow() and divmod()

print(pow(2, 5))
quotient, remainder = divmod(17, 5)
print(quotient, remainder)

range(): Generate Integer Sequences

for number in range(1, 6):
    print(number)

The stop value is excluded. You can also provide a step:

for number in range(10, 0, -2):
    print(number)

range() represents a sequence efficiently instead of building a full list immediately.

enumerate(): Loop with an Index

languages = ["Python", "JavaScript", "Go"]

for position, language in enumerate(languages, start=1):
    print(position, language)

This is clearer than maintaining a counter manually. Read the enumerate guide for more patterns.

zip(): Combine Iterables

names = ["Ana", "Ben", "Chloe"]
scores = [90, 84, 96]

for name, score in zip(names, scores):
    print(f"{name}: {score}")

By default, zip() stops when the shortest iterable ends. The zip guide explains strict matching and unzipping.

sorted() and reversed()

numbers = [8, 2, 10, 4]

ascending = sorted(numbers)
descending = sorted(numbers, reverse=True)
backward = list(reversed(numbers))

print(ascending)
print(descending)
print(backward)

sorted() returns a new list. The original collection remains unchanged. See sort versus sorted for custom keys and stable sorting.

any() and all()

any() returns true when at least one item is truthy. all() returns true when every item is truthy.

scores = [80, 55, 91]

print(any(score >= 90 for score in scores))
print(all(score >= 50 for score in scores))

These functions often make validation clearer than manual flags. The booleans guide explains truthy and falsy values.

map() and filter()

numbers = [1, 2, 3, 4]

squares = list(map(lambda number: number ** 2, numbers))
even_numbers = list(filter(lambda number: number % 2 == 0, numbers))

List comprehensions are often more readable for simple transformations:

squares = [number ** 2 for number in numbers]
even_numbers = [number for number in numbers if number % 2 == 0]

Choose the style that communicates the logic most clearly.

iter() and next()

iterator = iter([10, 20, 30])

print(next(iterator))
print(next(iterator))

iter() creates an iterator, and next() requests the next value. When no values remain, Python raises StopIteration. A default can avoid that exception:

print(next(iterator, None))

open(): Work with Files

with open("notes.txt", "r", encoding="utf-8") as file:
    content = file.read()

print(content)

Use a context manager so the file closes automatically. The text files guide and pathlib guide present safer file patterns.

help(), dir(), and callable()

print(callable(len))
print(dir(str)[:10])
help(str.strip)

help() displays documentation, dir() lists available attributes, and callable() checks whether an object can be called.

id(), hash(), and repr()

value = "Python"

print(id(value))
print(hash(value))
print(repr(value))

id() represents object identity during its lifetime. hash() supports hash-based collections. repr() returns a developer-oriented representation that is useful when debugging hidden characters.

getattr(), setattr(), and hasattr()

class User:
    def __init__(self, name: str):
        self.name = name


user = User("Mia")

print(hasattr(user, "name"))
print(getattr(user, "name"))
setattr(user, "active", True)
print(user.active)

These functions are useful in dynamic code, but direct attribute access is clearer when the attribute is known in advance.

Common Mistakes

  • Using a variable name such as list, sum, or max and hiding the built-in.
  • Forgetting that input() returns text.
  • Calling min() or max() on an empty sequence.
  • Assuming zip() checks equal lengths automatically.
  • Using round() as a complete financial precision solution.
  • Converting a lazy iterator to a list when streaming would be better.
  • Using eval() with untrusted input.

Avoid eval() on Untrusted Data

eval() executes a string as a Python expression. It can run dangerous code and should not be used to parse user input, JSON, or configuration files. Prefer explicit conversion functions, the json module, or a dedicated parser.

Practical Example

def summarize_scores(scores: list[float]) -> dict:
    if not scores:
        return {
            "count": 0,
            "minimum": None,
            "maximum": None,
            "average": None,
            "all_passed": False,
        }

    return {
        "count": len(scores),
        "minimum": min(scores),
        "maximum": max(scores),
        "average": sum(scores) / len(scores),
        "all_passed": all(score >= 60 for score in scores),
    }


summary = summarize_scores([72, 88, 65, 91])
for key, value in summary.items():
    print(f"{key}: {value}")

This small function combines len(), min(), max(), sum(), and all() in a readable solution.

Frequently Asked Questions

Do built-in functions require an import?

No. They are available directly in normal Python code.

Can I create a variable named list or sum?

Python allows it, but doing so hides the built-in function in that scope. Use a more descriptive name.

Are map and filter better than comprehensions?

Not automatically. Choose the form that makes the transformation easiest to understand.

How can I see every built-in?

Use the official built-in functions reference or inspect the builtins module.

Conclusion

Python built-in functions provide reliable building blocks for everyday programming. Start with input, output, conversion, counting, aggregation, sorting, iteration, and validation. Then explore inspection and object-related functions as your projects grow.

The goal is not to memorize every function. Learn to recognize common problems and consult the official reference when you need a tool. Using a clear built-in is usually better than rewriting the same logic manually.

Share:

Facebook
WhatsApp
Twitter
LinkedIn

Article content

    Related articles

    Logo do Python com expressão pensativa sobreposto a uma biblioteca com estantes cheias de livros, representando o conceito de bibliotecas em Python
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    Python Libraries: What They Are and How to Use Them

    Learn what Python libraries are, how modules and packages differ, how to install and import them, use virtual environments, and

    Ler mais

    Tempo de leitura: 6 minutos
    10/07/2026
    Logo do Python com o texto 'requests' abaixo
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    Python Requests: Complete Beginner Guide

    Learn Python Requests from scratch: install the library, send GET and POST requests, work with parameters, headers, JSON, timeouts, sessions,

    Ler mais

    Tempo de leitura: 4 minutos
    10/07/2026
    Manipulação de datas e calendário em Python
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    Python datetime: Work with Dates and Times

    Learn Python datetime: create, parse, format, compare, and calculate dates and times, use timedelta, UTC, zoneinfo, and aware datetimes.

    Ler mais

    Tempo de leitura: 5 minutos
    10/07/2026
    Barra de progresso com tqdm para scripts Python
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    Python tqdm: Add Progress Bars to Scripts

    Add progress bars to Python scripts with tqdm. Learn installation, loops, manual updates, files, pandas, nested bars, and practical options.

    Ler mais

    Tempo de leitura: 6 minutos
    10/07/2026
    Uso do módulo random para gerar valores aleatórios em Python
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    Python random Module: Complete Beginner Guide

    Learn Python's random module: generate numbers, choose items, shuffle lists, sample data, use seeds, and know when to use secrets.

    Ler mais

    Tempo de leitura: 5 minutos
    10/07/2026
    Manipulação moderna de arquivos usando pathlib em Python
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    Python pathlib: Manage Files and Paths Easily

    Learn Python pathlib to create, inspect, read, write, rename, move, and delete files and folders with clean cross-platform code.

    Ler mais

    Tempo de leitura: 5 minutos
    10/07/2026