PYnative

Practice Coding

  • Python â–¼
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Coding Exercises â–¼
    • Python Exercises
    • C++ Exercises
    • C Programming Exercises
    • Java Exercises
    • C# Exercises
  • MCQsâ–¼
    • Python MCQ Quizzes
    • Java MCQ Quizzes
    • C++ MCQ Quizzes
  • Compilersâ–¼
    • Online Python Compiler
    • Online C Compiler
    • Online C++ Compiler
    • Online Java Compiler
    • Online C# Compiler
Home » Python » Basics » Python Built-In Functions: The Complete List With Examples

Python Built-In Functions: The Complete List With Examples

Updated on: December 4, 2026 | Leave a Comment

Python comes with a set of built-in functions that are always available. You don’t need to import anything to use print(), len(), range(), or sorted(). They’re part of the language itself, and knowing them well saves you from writing code that Python already provides.

This guide lists all 71 built-in functions in Python 3.10 and later, explains what each one does in one line, and then walks through the important ones by category with runnable examples.

Key terms used in this article:

  • Built-in function: A function that’s always available in Python without an import, such as len() or print().
  • Iterable: Any object you can loop over, such as a list, tuple, string, set, dictionary, or range.
  • Iterator: An object that produces items one at a time with next(). Many built-ins, such as map() and zip(), return iterators.
  • Callable: Anything you can call with parentheses, such as a function or a class.

Table of contents

  • How to see all built-in functions
  • Complete list of Python built-in functions
  • Math and number functions
    • round() uses banker’s rounding
    • min() and max() with key and default
  • Type conversion functions
  • Number system and character functions
  • Iteration and sequence functions
    • len(), range(), enumerate(), and zip()
    • sorted() and reversed()
    • all() and any()
    • map() and filter()
    • iter() and next()
    • slice()
  • Input and output functions
  • Object and type inspection functions
    • dir() and vars()
  • Attribute functions
  • Class and OOP helpers
  • Code execution functions
  • Scope functions: globals() and locals()
  • Memory and binary data functions
  • Debugging with breakpoint()
  • Async iteration: aiter() and anext()
  • Don’t shadow built-in names
  • Practice exercises
  • Summary

How to see all built-in functions

Built-in functions live in the builtins module. You can list them from Python itself:

import builtins

names = [
    name for name in dir(builtins)
    if not name.startswith("_") and callable(getattr(builtins, name))
    and not (isinstance(getattr(builtins, name), type)
             and issubclass(getattr(builtins, name), BaseException))
]
print(len(names))
print(names[:10])Code language: Python (python)

Output:

75
['abs', 'aiter', 'all', 'anext', 'any', 'ascii', 'bin', 'bool', 'breakpoint', 'bytearray']

This count includes a few helpers added by the site module for the interactive shell (exit, quit, copyright, credits, and license) and leaves out __import__. The official documentation lists 71 built-in functions, which are covered below. Use help(name) to read the documentation of any of them, for example help(sorted).

Some entries, such as int, str, list, and range, are actually classes. They’re listed as built-in functions because you call them like functions to create or convert values.

Complete list of Python built-in functions

FunctionDescription
abs(x)Returns the absolute value of a number
aiter(async_iterable)Returns an asynchronous iterator (Python 3.10+)
all(iterable)Returns True if every item is truthy (or the iterable is empty)
anext(async_iterator)Awaits and returns the next item of an async iterator (Python 3.10+)
any(iterable)Returns True if at least one item is truthy
ascii(obj)Returns a printable representation with non-ASCII characters escaped
bin(n)Converts an integer to a binary string, such as '0b101'
bool(x)Converts a value to True or False
breakpoint()Pauses the program and opens the debugger
bytearray(source)Returns a mutable sequence of bytes
bytes(source)Returns an immutable sequence of bytes
callable(obj)Returns True if the object can be called
chr(i)Returns the character for a Unicode code point
classmethod(func)Turns a method into a class method (usually used as @classmethod)
compile(source, filename, mode)Compiles source code into a code object
complex(real, imag)Creates a complex number
delattr(obj, name)Deletes an attribute from an object
dict()Creates a dictionary
dir(obj)Lists the names (attributes and methods) of an object or the current scope
divmod(a, b)Returns the quotient and remainder as a tuple
enumerate(iterable, start=0)Returns pairs of (index, item)
eval(expression)Evaluates a string as a Python expression and returns the result
exec(code)Executes Python code stored in a string or code object
filter(function, iterable)Keeps the items for which the function returns a truthy value
float(x)Converts a value to a floating-point number
format(value, spec)Formats a value using a format specifier
frozenset(iterable)Creates an immutable set
getattr(obj, name, default)Gets an attribute by name
globals()Returns the dictionary of the current global variables
hasattr(obj, name)Returns True if the object has the attribute
hash(obj)Returns the hash value of an object
help(obj)Shows the built-in help system
hex(n)Converts an integer to a hexadecimal string
id(obj)Returns the unique identity (memory address in CPython) of an object
input(prompt)Reads a line of text from the user
int(x, base=10)Converts a value to an integer
isinstance(obj, classinfo)Checks whether an object is an instance of a class
issubclass(cls, classinfo)Checks whether a class is a subclass of another
iter(obj)Returns an iterator for an object
len(obj)Returns the number of items in an object
list(iterable)Creates a list
locals()Returns a dictionary of the current local variables
map(function, iterable, ...)Applies a function to every item
max(iterable)Returns the largest item
memoryview(obj)Returns a memory view of a bytes-like object without copying it
min(iterable)Returns the smallest item
next(iterator, default)Returns the next item from an iterator
object()Returns a new featureless object, the base of all classes
oct(n)Converts an integer to an octal string
open(file, mode)Opens a file and returns a file object
ord(c)Returns the Unicode code point of a character
pow(base, exp, mod)Returns base to the power exp, optionally modulo mod
print(*objects)Prints objects to the screen or a file
property(fget, fset)Creates a managed attribute (usually used as @property)
range(start, stop, step)Returns an immutable sequence of numbers
repr(obj)Returns the developer-friendly string representation
reversed(seq)Returns a reverse iterator
round(number, ndigits)Rounds a number
set(iterable)Creates a set
setattr(obj, name, value)Sets an attribute by name
slice(start, stop, step)Creates a slice object
sorted(iterable, key, reverse)Returns a new sorted list
staticmethod(func)Turns a method into a static method (usually used as @staticmethod)
str(obj)Converts a value to a string
sum(iterable, start=0)Adds up the items
super()Gives access to methods of a parent class
tuple(iterable)Creates a tuple
type(obj)Returns the type of an object (or creates a new class with three arguments)
vars(obj)Returns the __dict__ of an object
zip(*iterables)Combines several iterables item by item
__import__(name)Imports a module (used internally by the import statement)

Math and number functions

abs(), round(), pow(), divmod(), sum(), min(), and max() cover everyday calculations.

print(abs(-7.5))
print(round(3.14159, 2))
print(round(1234.5678, -2))   # round to hundreds
print(pow(2, 10))
print(pow(2, 10, 1000))       # (2 ** 10) % 1000, but faster
print(divmod(17, 5))
print(sum([10, 20, 30]))
print(sum([10, 20, 30], start=100))
print(min(4, 9, 1), max(4, 9, 1))Code language: Python (python)

Output:

7.5
3.14
1200.0
1024
24
(3, 2)
60
160
1 9

round() uses banker’s rounding

round() rounds halves to the nearest even number. This avoids bias in large datasets, but it surprises many beginners:

print(round(0.5), round(1.5), round(2.5), round(3.5))Code language: Python (python)

Output:

0 2 2 4

min() and max() with key and default

words = ["kiwi", "banana", "fig", "cherry"]
print(max(words, key=len))
print(min(words, key=len))

print(max([], default=0))  # avoids ValueError on an empty list

prices = {"apple": 1.2, "mango": 2.5, "plum": 0.8}
print(max(prices, key=prices.get))Code language: Python (python)

Output:

banana
fig
0
mango

Type conversion functions

These functions create values of a type or convert from one type to another: int(), float(), str(), bool(), complex(), list(), tuple(), set(), frozenset(), dict(), bytes(), and bytearray().

print(int("42") + 1)
print(int(9.99))          # truncates toward zero
print(int("ff", 16))      # base 16
print(int("0b1010", 0))   # base 0 reads the prefix
print(float("3.5"))
print(str(100) + "%")
print(bool(0), bool(""), bool([]), bool("no"))
print(complex(2, 3))Code language: Python (python)

Output:

43
9
255
10
3.5
100%
False False False True
(2+3j)
print(list("abc"))
print(tuple([1, 2, 3]))
print(set([1, 2, 2, 3, 3]))
print(dict([("a", 1), ("b", 2)]))
print(dict(name="Jessa", age=28))
print(frozenset({1, 2}))
print(bytes("hi", "utf-8"))Code language: Python (python)

Output:

['a', 'b', 'c']
(1, 2, 3)
{1, 2, 3}
{'a': 1, 'b': 2}
{'name': 'Jessa', 'age': 28}
frozenset({1, 2})
b'hi'

See Python Casting: Type Conversion and Type Casting for more detail.

Number system and character functions

print(bin(10), oct(10), hex(255))
print(ord("A"), chr(65))
print(ord("€"), chr(8364))
print(format(255, "08b"))
print(format(1234567.891, ",.2f"))
print(ascii("café"))Code language: Python (python)

Output:

0b1010 0o12 0xff
65 A
8364 €
11111111
1,234,567.89
'caf\xe9'

Iteration and sequence functions

These functions work with any iterable and are used constantly in real code.

len(), range(), enumerate(), and zip()

fruits = ["apple", "banana", "cherry"]
prices = [1.2, 0.5, 3.0]

print(len(fruits))
print(list(range(2, 11, 3)))

for index, fruit in enumerate(fruits, start=1):
    print(index, fruit)

for fruit, price in zip(fruits, prices):
    print(f"{fruit}: ${price}")Code language: Python (python)

Output:

3
[2, 5, 8]
1 apple
2 banana
3 cherry
apple: $1.2
banana: $0.5
cherry: $3.0

zip() stops at the shortest iterable. Pass strict=True (Python 3.10+) to raise an error when the lengths differ.

names = ["Jessa", "Kelly", "Emma"]
ages = [28, 31]

print(list(zip(names, ages)))

try:
    list(zip(names, ages, strict=True))
except ValueError as error:
    print("Error:", error)Code language: Python (python)

Output:

[('Jessa', 28), ('Kelly', 31)]
Error: zip() argument 2 is shorter than argument 1

sorted() and reversed()

sorted() returns a new list and works on any iterable. reversed() returns an iterator over a sequence in reverse order.

numbers = [5, 2, 9, 1]
print(sorted(numbers))
print(sorted(numbers, reverse=True))
print(numbers)  # original is unchanged
print(sorted("python"))
print(list(reversed(numbers)))
print("".join(reversed("hello")))Code language: Python (python)

Output:

[1, 2, 5, 9]
[9, 5, 2, 1]
[5, 2, 9, 1]
['h', 'n', 'o', 'p', 't', 'y']
[1, 9, 2, 5]
olleh

all() and any()

scores = [72, 88, 95, 61]
print(all(s >= 60 for s in scores))   # everyone passed?
print(any(s >= 90 for s in scores))   # anyone above 90?
print(all([]), any([]))               # empty iterablesCode language: Python (python)

Output:

True
True
True False

map() and filter()

numbers = ["3", "8", "15"]
print(list(map(int, numbers)))
print(list(filter(lambda n: n % 2, [1, 2, 3, 4, 5])))
print(list(filter(None, [0, 1, "", "a", None, [], [2]])))Code language: Python (python)

Output:

[3, 8, 15]
[1, 3, 5]
[1, 'a', [2]]

Passing None to filter() keeps only truthy items. For details, see Lambda Functions in Python.

iter() and next()

colors = iter(["red", "green"])
print(next(colors))
print(next(colors))
print(next(colors, "no more items"))  # default instead of StopIterationCode language: Python (python)

Output:

red
green
no more items

slice()

A slice object stores start, stop, and step, so you can reuse the same slice:

first_three = slice(0, 3)
every_other = slice(None, None, 2)

data = [10, 20, 30, 40, 50, 60]
print(data[first_three])
print(data[every_other])
print("Python"[first_three])Code language: Python (python)

Output:

[10, 20, 30]
[10, 30, 50]
Pyt

Input and output functions

print(), input(), and open() handle communication with users and files.

print("a", "b", "c")
print("a", "b", "c", sep="-")
print("no newline", end=" | ")
print("same line")

with open("notes.txt", "w") as file:
    print("Saved with print()", file=file)

with open("notes.txt") as file:
    print(file.read().strip())Code language: Python (python)

Output:

a b c
a-b-c
no newline | same line
Saved with print()

input() always returns a string, so convert it when you need a number:

age = int(input("Enter your age: "))
print(f"Next year you'll be {age + 1}")Code language: Python (python)

See Python Input: Take Input from User for more.

Object and type inspection functions

These functions let you inspect objects at runtime: type(), isinstance(), issubclass(), id(), hash(), callable(), dir(), vars(), repr(), and help().

value = [1, 2, 3]

print(type(value))
print(type(value).__name__)
print(isinstance(value, list))
print(isinstance(3.5, (int, float)))  # tuple of types
print(issubclass(bool, int))
print(callable(len), callable(value))
print(hash("python") == hash("python"))
print(repr("text"), str("text"))Code language: Python (python)

Output:

<class 'list'>
list
True
True
True
True False
True
'text' text

Prefer isinstance() over type(x) == SomeType, because isinstance() also accepts subclasses.

dir() and vars()

class Book:
    def __init__(self, title, pages):
        self.title = title
        self.pages = pages

book = Book("Python 101", 250)
print(vars(book))
print([name for name in dir(book) if not name.startswith("_")])Code language: Python (python)

Output:

{'title': 'Python 101', 'pages': 250}
['pages', 'title']

Attribute functions

getattr(), setattr(), hasattr(), and delattr() work with attributes whose names are stored in strings:

class Config:
    debug = False

settings = Config()

print(getattr(settings, "debug"))
print(getattr(settings, "port", 8000))  # default if missing
setattr(settings, "port", 5000)
print(hasattr(settings, "port"))
delattr(settings, "port")
print(hasattr(settings, "port"))Code language: Python (python)

Output:

False
8000
True
False

Class and OOP helpers

classmethod(), staticmethod(), property(), super(), and object() are mostly used as decorators or inside classes:

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

    def speak(self):
        return "..."


class Dog(Animal):
    count = 0

    def __init__(self, name, breed):
        super().__init__(name)  # call the parent constructor
        self.breed = breed
        Dog.count += 1

    def speak(self):
        return "Woof"

    @property
    def description(self):
        return f"{self.name} the {self.breed}"

    @classmethod
    def how_many(cls):
        return cls.count

    @staticmethod
    def is_valid_name(name):
        return name.isalpha()


rex = Dog("Rex", "beagle")
print(rex.description)
print(rex.speak())
print(Dog.how_many())
print(Dog.is_valid_name("Rex1"))Code language: Python (python)

Output:

Rex the beagle
Woof
1
False

Code execution functions

eval() evaluates an expression stored in a string, exec() executes statements, and compile() turns source code into a code object.

print(eval("2 + 3 * 4"))

code = """
total = 0
for n in range(5):
    total += n
"""
namespace = {}
exec(code, namespace)
print(namespace["total"])Code language: Python (python)

Output:

14
10

Security warning: Never pass user input to eval() or exec(). They run any code, including code that deletes files or reads secrets. To safely convert a string such as "[1, 2, 3]" into a Python object, use ast.literal_eval() instead.

import ast
print(ast.literal_eval("[1, 2, {'a': 3}]"))Code language: Python (python)

Output:

[1, 2, {'a': 3}]

Scope functions: globals() and locals()

site = "PYnative"

def show_scope():
    count = 3
    print(locals())

show_scope()
print("site" in globals())Code language: Python (python)

Output:

{'count': 3}
True

Memory and binary data functions

bytes(), bytearray(), and memoryview() work with raw binary data:

data = bytearray(b"hello")
data[0] = ord("H")       # bytearray is mutable
print(data)

view = memoryview(data)
print(view[1:4].tobytes())  # no copy is madeCode language: Python (python)

Output:

bytearray(b'Hello')
b'ell'

Debugging with breakpoint()

breakpoint() stops your program and opens the pdb debugger at that line, so you can inspect variables, step through code, and continue (type c) or quit (type q).

def average(numbers):
    total = sum(numbers)
    breakpoint()  # program pauses here
    return total / len(numbers)Code language: Python (python)

Async iteration: aiter() and anext()

aiter() and anext() are the asynchronous versions of iter() and next(), used with async for and async generators:

import asyncio

async def countdown(n):
    while n > 0:
        yield n
        n -= 1

async def main():
    it = aiter(countdown(3))
    print(await anext(it))
    print(await anext(it))
    print(await anext(it, "done"))
    print(await anext(it, "done"))

asyncio.run(main())Code language: Python (python)

Output:

3
2
1
done

Don’t shadow built-in names

Built-in names aren’t reserved keywords, so you can accidentally overwrite them with your own variables. After that, the built-in function is unavailable in that scope:

list = [1, 2, 3]  # shadows the built-in list()

try:
    numbers = list("abc")
except TypeError as error:
    print("Error:", error)

del list  # remove the shadowing variable
print(list("abc"))Code language: Python (python)

Output:

Error: 'list' object is not callable
['a', 'b', 'c']

Avoid naming variables list, dict, str, id, input, sum, max, min, type, or filter. Use descriptive names such as items, user_id, or total instead.

Practice exercises

Exercise 1: Given a list of numbers as strings, convert them to integers and print their sum, minimum, maximum, and average rounded to 2 decimals.

raw = ["12", "7", "33", "18", "5"]
numbers = list(map(int, raw))
print(sum(numbers), min(numbers), max(numbers), round(sum(numbers) / len(numbers), 2))Code language: Python (python)

Output:

75 5 33 15.0

Exercise 2: Combine two lists into a dictionary and print the key with the highest value.

names = ["Jessa", "Kelly", "Emma"]
scores = [82, 95, 77]
results = dict(zip(names, scores))
print(results)
print(max(results, key=results.get))Code language: Python (python)

Output:

{'Jessa': 82, 'Kelly': 95, 'Emma': 77}
Kelly

Exercise 3: Print each character of a word with its Unicode code point in binary.

for index, ch in enumerate("Hi!", start=1):
    print(index, ch, ord(ch), bin(ord(ch)))Code language: Python (python)

Output:

1 H 72 0b1001000
2 i 105 0b1101001
3 ! 33 0b100001

Summary

  • Python has 71 built-in functions that are available without importing anything.
  • Use abs(), round(), pow(), divmod(), sum(), min(), and max() for math.
  • Use int(), float(), str(), bool(), list(), tuple(), set(), and dict() to convert and create values.
  • Use len(), range(), enumerate(), zip(), sorted(), reversed(), map(), filter(), all(), and any() to work with iterables.
  • Use type(), isinstance(), dir(), vars(), getattr(), and hasattr() to inspect objects.
  • Avoid eval() and exec() on untrusted input, and never shadow built-in names with your own variables.

Also, See:

  • Python Functions
  • Python range() Explained with Examples
  • Python isinstance() function explained with examples
  • Python Basic Exercise for Beginners

Filed Under: Python, Python Basics

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners. Follow me on Twitter.

Related Tutorial Topics:

Python Python Basics

All Coding Exercises:

C Exercises
C++ Exercises
Python Exercises
Java Exercises
C# Exercises

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 25+ questions
  • Each Quiz contains 25 MCQ
Exercises
Quizzes

Leave a Reply Cancel reply

your email address will NOT be published. all comments are moderated according to our comment policy.

Use <pre> tag for posting code. E.g. <pre> Your entire code </pre>

In: Python Python Basics
TweetF  sharein  shareP  Pin

  Python Tutorials

  • Get Started with Python
  • Python Statements
  • Python Comments
  • Python Keywords
  • Python Variables
  • Python Operators
  • Python Data Types
  • Python Casting
  • Python Control Flow statements
  • Python For Loop
  • Python While Loop
  • Python Break and Continue
  • Python Nested Loops
  • Python Input and Output
  • Python range function
  • Check user input is String or Number
  • Accept List as a input from user
  • Python Numbers
  • Python Lists
  • Python Tuples
  • Python Sets
  • Python Dictionaries
  • Python Functions
  • Python Modules
  • Python isinstance()
  • Python OOP
  • Python Inheritance
  • Python Exceptions
  • Python Exercise for Beginners
  • Python Quiz for Beginners

 Explore Python

  • Python Tutorials
  • Python Exercises
  • Python Quizzes
  • Python Interview Q&A
  • Python Programs

All Python Topics

  • Python Basics
  • Python Exercises
  • Python Quizzes
  • Python File Handling
  • Python Date and Time
  • Python OOP
  • Python Random
  • Python Regex
  • Python Pandas
  • Python Databases
  • Python MySQL
  • Python PostgreSQL
  • Python SQLite
  • Python JSON

About PYnative

PYnative.com is a platform built to help developers learn by doing. Solve coding exercises, take MCQs, and run code directly in built-in online compilers.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises
  • Java Exercises
  • C# Exercises

MCQ Quizzes

  • Python MCQs
  • Java MCQs
  • C++ MCQs

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2026 pynative.com