Skip to content

Python Built-In Functions

Python comes built-in with a number of functions that are always available unless explicitly overwritten. The table below provides all functions available in Python 3, as well as dedicated tutorials.

Function NameFunction Description
abs()Returns the absolute value of an integer, floating point value, or an object that implements abs(). If the argument is a complex number, the magnitude of that number is returned.
aiter()Returns an asynchronous iterator for an asynchronous iterable.
all()Returns True if all the elements in the passed in iterable are true (or if the iterable is empty).
any()Returns True is any of the elements in the passed-in iterable are True, otherwise return False. If the iterable if empty, return False.
anext()When awaited, return the next item from the given asynchronous iterator, or default if given and the iterator is exhausted.
ascii()Returns a string containing the printable representation of an object but escapes the non-ASCII characters.
bin()Convert an integer number to a binary string that is prefixed with “0b”.
bool()Returns a boolean value using standard truth testing procedures. If the passed in value is false or empty; otherwise, it returns True.
breakpoint()The function is used to drop the program into a debugger at the point that it’s called at.
bytearray()Returns a new array of bytes.
bytes()Returns a new “bytes” object which is an immutable sequence of integers in the range of 0 to 256 (inclusive). It returns an immutable version of the bytearray.
callable()Returns True if the object arguments callable, otherwise False. Even if the function returns True, the call may still fail.
chr()Returns the string representing a character where the Unicode code point is the integer of the value passed in. The valid range is from 0 to 1,114,111 and the function will raise a ValueError if the value is outside of the range.
classmethod()Is used as a decorator to transform a method into a class method. This means that the method receives the class as an implicit first argument.
compile()Is used to compile the source into a code or AST object.
complex()Returns a complex number with the value real + imag*1j or convert a string or number to a complex number.
delattr()The function accepts an object and a string and is used to delete the named attribute if the object allows it.
dict()Creates a new dictionary.
dir()Without any arguments, the function returns the list of names in the current local scope.If an argument is passed in, returns a list of valid attributes for that object.
divmod()Takes two non-complex numbers and returns a pair of numbers that represent the quotient and the remainder when using integer division (a // b, a % b).
enumerate()Is used to return an enumerate object, which returns an index and the object from the iterable that is passed in.
eval()Parses the expression passed to this method and runs python expression (code) within the program.
exec()Executes a dynamically created program, which is either a string or a code object.
filter()Is used to construct an an iterator from the elements of the passed-in iterable for which the return returns True.
float()Return a floating point number constructed from a number or string x.
format()Converts a value to a formatted representation.
frozenset()Returns a frozenset object.
getattr()Returns the value of the named attribute of the object, where the name must be a string.
globals()Returns the dictionary implementing the current module namespace.
hasattr()The arguments are an object and a string and returns True if the string is in the name of one of the attributes, otherwise False.
hash()Returns the hash value of the object if it has one. This allows you to compare dictionary keys during a dictionary lookup.
help()Invokes the built-in help system in the interactive use.
hex()Converts an integer number to a lowercase hexadecimal string prefixed with “0x”.
id()Is used to return the identity of an object. The identity is guaranteed to be unique and constant for the object during the object’s lifetime.
input()If a prompt is present, the prompt is written to the standard output without a trailing newline. The function is used to read a line from the input and converts it to a string.
int()Returns an integer object that is constructed from a number or string. If no argument is provided, the function returns 0.
isinstance()Returns True if the object argument is an instance of the classinfo argument (or of a subclass of the classinfo).
issubclass()Returns True if class is a subclass of class info. A class is also considered a subclass of itself. Accepts a tuple of class objects.
iter()Returns an iterator object.
len()Returns the length of an object, which may be a sequence (such as a string or list) or a collection (such as a dictionary or set).
list()Is a mutable sequence type, rather than a function.
locals()Update and return a dictionary representing the current lcaol symbol table.
map()Returns an iterator that applies the function to every item of the iterable, yielding the results.
max()Returns the largest item in an iterable or the largest of two or more arguments. Allows you to pass in a key that is used to determine the max by sorting an iterable.
memoryview()Returns a memory view object created from the given argument.
min()Returns the smallest item in an iterable or the largest of two or more arguments. Allows you to pass in a key that is used to determine the min by sorting an iterable.
next()Retrieves the next item from an iterator by calling its __next__() method. If a default value is provided, it is returned if the iterator is exhausted.
object()Is used to return a new featureless object.
oct()Is used to convert an integer number to an octal string prefixed with “0a”.
open()Is used to open the file passed in an return a corresponding file object.
ord()Given a string representation of a single Unicode character, returns an integer representing the Unicode code point of that character.
pow()Return base to the power exp. If mod is present, returns the base to the power exp, modulo mod.
print()Is used to print objects to the text stream file, separated by sep and followed by end.
property()Is used to return a property attribute.
range()While not a function, it represents an immutable sequence type.
repr()Returns a string containing a printable representation of an object.
reversed()Return a reverse iterator. The sequence must have a __reversed__() method.
round()Is used to return the number rounded to ndigits precision after the decimal point. If no ndigits are provided, the number is rounded to the nearest integer.
set()Returns a new set object, optionally with the elements taken from an iterable.
setattr()The arguments are an object, a string, and an arbitrary value and is used to assign the value to the attribute.
slice()Returns a slice object representing the set of indeices specific by range(start, stop, step).
sorted()Returns a new sorted list from the items in the iterable. Allows you to pass in a key by which to compare values. Allows you to reverse the sequence using the reverse parameter.
staticmethod()Is used to transform a method into a static method, which does not receive an implicit first argument.
str()rturns a string version of the passed-in object.
sum()Sums the items of an iterable from left to right.
super()Return a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been overridden in a class.
tuple()Is an immutable sequence type, rather than a function.
type()Returns the type of an object. The isinstance() function is preferred, as it takes subclasses into account.
vars()Returns the __dict__ attribute for a module, class, instance, or other object that has a __dict__ attribute.
zip()Iterates over several iterables in parallel, producing tuples with an item from each one.
__import()The function is invoked by an import statement.
All built-in Python functions