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.
This table provides all the built-in Python functions, including descriptions of what they do. The table is sortable by the function's starting letter and by its type (i.e., function, class, decorator, or awaitable).
Function Name | Code | Description | Tutorial | ||||
---|---|---|---|---|---|---|---|
A | abs() | Function | abs(x) | 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. | https://datagy.io/python-absolute-value/ | Tutorial for abs() | Arithmetic |
A | aiter() | Function | aiter(async_iterable) | Returns an asynchronous iterator for an asynchronous iterable. | Aync Function | ||
A | all() | Function | all(iterable) | Returns True if all the elements in the passed in iterable are true (or if the iterable is empty). | Comparisons | ||
A | any() | Function | any(iterable) | Returns True is any of the elements in the passed-in iterable are True, otherwise return False. If the iterable if empty, return False. | Comparisons | ||
A | anext() | Awaitable | anext(async_iterator), anext(async_iterator, default) | When awaited, return the next item from the given asynchronous iterator, or default if given and the iterator is exhausted. | Aync Function | ||
A | ascii() | Function | ascii(object) | Returns a string containing the printable representation of an object but escapes the non-ASCII characters. | String Conversions | ||
B | bin() | Function | bin(x) | Convert an integer number to a binary string that is prefixed with "0b". | https://datagy.io/python-int-to-binary/ | Tutorial for bin() | Numeric Conversion |
B | bool() | Class | bool(x=False) | Returns a boolean value using standard truth testing procedures. If the passed in value is false or empty; otherwise, it returns True. | Numeric Conversion | ||
B | breakpoint() | Function | breakpoint(*args, **kws) | The function is used to drop the program into a debugger at the point that it's called at. | System Function | ||
B | bytearray() | Class | bytearray(source=b''), bytearray(source, encoding), bytearray(source, encoding, errors) | Returns a new array of bytes. | Sequence Constructor | ||
B | bytes() | Class | bytes(source=b''), bytes(source, encoding), bytes(source, encoding, errors) | 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. | String Conversions | ||
C | callable() | Function | callable(object) | Returns True if the object arguments callable, otherwise False. Even if the function returns True, the call may still fail. | Information Function | ||
C | chr() | Function | chr(i) | 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. | https://datagy.io/python-ord-chr/ | Tutorial for chr() | String Conversions |
C | classmethod() | Decorator | @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. | Object-Oriented Function | ||
C | compile() | Function | compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1) | Is used to compile the source into a code or AST object. | System Function | ||
C | complex() | Class | complex(real=0, imag=0), complex(string) | Returns a complex number with the value real + imag*1j or convert a string or number to a complex number. | Numeric Conversion | ||
D | delattr() | Function | delattr(object, name) | The function accepts an object and a string and is used to delete the named attribute if the object allows it. | Object-Oriented Function | ||
D | dict() | Class | dict(**kwargs), dict(mapping, **kwarg), dict(iterable, **kwarg) | Creates a new dictionary. | Mapping Constructor | ||
D | dir() | Function | dir(), dir(object) | 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. | https://datagy.io/python-print-objects-attributes/ | Tutorial for dir() | Object-Oriented Function |
D | divmod() | Function | divmod(a, b) | 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). | https://datagy.io/python-divmod/ | Tutorial for divmod() | Arithmetic |
E | enumerate() | Function | enumerate(iterable, start=0) | Is used to return an enumerate object, which returns an index and the object from the iterable that is passed in. | https://datagy.io/python-enumerate/ | Tutorial for enumerate() | Container Operator |
E | eval() | Function | eval(expression, /, globals=None, locals=None) | Parses the expression passed to this method and runs python expression (code) within the program. | System Function | ||
E | exec() | Function | exec(object, globs=None, locals=None, *, closure=None) | Executes a dynamically created program, which is either a string or a code object. | System Function | ||
F | filter() | Function | filter(function, iterable) | Is used to construct an an iterator from the elements of the passed-in iterable for which the return returns True. | https://datagy.io/python-filter/ | Tutorial for filter() | Functional Programming |
F | float() | Class | float(x=0.0) | Return a floating point number constructed from a number or string x. | Numeric Conversion | ||
F | format() | Function | format(value, format_spec='') | Converts a value to a formatted representation. | String Conversions | ||
F | frozenset() | Class | frozenset(iterable=set()) | Returns a frozenset object. | Mapping Constructor | ||
G | getattr() | Function | getattr(object, name), getattr(object, name, default) | Returns the value of the named attribute of the object, where the name must be a string. | Object-Oriented Function | ||
G | globals() | Function | globals() | Returns the dictionary implementing the current module namespace. | Information Function | ||
H | hasattr() | Function | hasttr(object, name) | 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. | Object-Oriented Function | ||
H | hash() | Function | hash(object) | Returns the hash value of the object if it has one. This allows you to compare dictionary keys during a dictionary lookup. | Identity | ||
H | help() | Function | help(), help(request) | Invokes the built-in help system in the interactive use. | Information Function | ||
H | hex() | Function | hex(x) | Converts an integer number to a lowercase hexadecimal string prefixed with "0x". | Numeric Conversion | ||
I | id() | Function | id(object) | 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. | Identity | ||
I | input() | Function | input(), input(prompt) | 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. | System Function | ||
I | int() | Class | int(x=0), int(x, base=10) | Returns an integer object that is constructed from a number or string. If no argument is provided, the function returns 0. | Numeric Conversion | ||
I | isinstance() | Function | isinstance(object, classinfo) | Returns Tre if the object argument is an instance of the classinfo argument (or of a subclass of the classinfo). | https://datagy.io/python-isinstance/ | Tutorial for isinstance() | Object-Oriented Function |
I | issubclass() | Function | issubclass(class, classinfo) | 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. | Object-Oriented Function | ||
I | iter() | Function | iter(object), iter(object, sentinal) | Returns an iterator object. | Iterators | ||
L | len() | Function | len(s) | 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). | Container Operator | ||
L | list() | Class | list(), list(iterable) | Is a mutable sequence type, rather than a function. | Sequence Constructor | ||
L | locals() | Function | locals() | Update and return a dictionary representing the current lcaol symbol table. | Information Function | ||
M | map() | Function | map(function, iterable, *iterables) | Returns an iterator that applies the function to every item of the iterable, yielding the results. | https://datagy.io/python-map/ | Tutorial for map() | Functional Programming |
M | max() | Function | max(iterable, *, key=None), max(iterable, *, default, key=None), max(arg1, arg2, *args, key=None) | 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. | Comparisons | ||
M | memoryview() | Class | memoryview(object) | Returns a memory view object created from the given argument. | Sequence Constructor | ||
M | min() | Function | min(iterable, *, key=None), min(iterable, *, default, key=None), min(arg1, arg2, *args, key=None) | 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. | Comparisons | ||
N | next() | Function | next(iterator), next(iterator, default) | 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. | Iterators | ||
O | object() | Class | object() | Is used to return a new featureless object. | Object-Oriented Function | ||
O | oct() | Function | oct(x) | Is used to convert an integer number to an octal string prefixed with "0a". | String Conversions | ||
O | open() | Function | open(file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | Is used to open the file passed in an return a corresponding file object. | Object-Oriented Function | ||
O | ord() | Function | ord(c) | Given a string representation of a single Unicode character, returns an integer representing the Unicode code point of that character. | https://datagy.io/python-ord-chr/ | Tutorial for ord() | String Conversions |
P | pow() | Function | pow(base, exp, mod=None) | Return base to the power exp. If mod is present, returns the base to the power exp, modulo mod. | https://datagy.io/python-exponentiation/ | Tutorial for pow() | Arithmetic |
P | print() | Function | print(*objects, sep=' ', end='n', file=None, flush=False) | Is used to print objects to the text stream file, separated by sep and followed by end. | System Function | ||
P | property() | Class | propert(fget=None, fset=None, fdel=None, doc=None) | Is used to return a property attribute. | Object-Oriented Function | ||
R | range() | Class | range(stop), range(start, stop, step=1) | While not a function, it represents an immutable sequence type. | https://datagy.io/python-range/ | Tutorial for range() | Sequence Constructor |
R | repr() | Function | repr(object) | Returns a string containing a printable representation of an object. | String Conversions | ||
R | reversed() | Function | reversed(seq) | Return a reverse iterator. The sequence must have a __reversed__() method. | Container Operator | ||
R | round() | Function | round(number, ndigits=None) | 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. | Arithmetic | ||
S | set() | Class | set(), set(iterable) | Returns a new set object, optionally with the elements taken from an iterable. | Mapping Constructor | ||
S | setattr() | Function | setattr(object, name, value) | The arguments are an object, a string, and an arbitrary value and is used to assign the value to the attribute. | Object-Oriented Function | ||
S | slice() | Class | slice(stop), slice(start, stop, step=1) | Returns a slice object representing the set of indeices specific by range(start, stop, step). | Container Operator | ||
S | sorted() | Function | sorted(iterable, /, *, key=None, reverse=False) | 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. | Container Operator | ||
S | staticmethod() | Decorator | @staticmethod | Is used to transform a method into a static method, which does not receive an implicit first argument. | Object-Oriented Function | ||
S | str() | Class | str(object=''), str(object=b'', encoding='utf-8', errors='strict') | rturns a string version of the passed-in object. | Sequence Constructor | ||
S | sum() | Function | sum(iterable, /, start=0) | Sums the items of an iterable from left to right. | Container Operator | ||
S | super() | Class | super(), super(type, object_or_type=None) | 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. | Object-Oriented Function | ||
T | tuple() | Class | tuple(), tuple(iterable) | Is an immutable sequence type, rather than a function. | Sequence Constructor | ||
T | type() | Class | type(object), type(name, bases, dict, **kwds) | Returns the type of an object. The isinstance() function is preferred, as it takes subclasses into account. | https://datagy.io/python-type-isinstance/ | Tutorial for type() | Object-Oriented Function |
V | vars() | Function | vars(), vars(object) | Returns the __dict__ attribute for a module, class, instance, or other object that has a __dict__ attribute. | Object-Oriented Function | ||
Z | zip() | Function | zip(*iterables, strict=False) | Iterates over several iterables in parallel, producing tuples with an item from each one. | https://datagy.io/python-zip-lists/ | Tutorial for zip() | Container Operator |
_ | __import() | Function | __import__(name, globals=None, locals=None, fromlist=(), level=0) | The function is invoked by an import statement. | System Function |