Python Built-in functions

Built-in functions

The Python programming language offers several functions that are available instantly, without the need to import any module. These functions are called Python built-in functions. On this page, an overview of the available functions and a short summary is given.
function description
abs() The abs() function returns the absolute value of an integer, float, or the magnitude of a complex number.
all() The all() function returns True if all the elements in an iterable are True. If not it returns False.
any() The any() function returns True if any element in an iterable is True. If none of the elements is True, it returns False.
ascii() The ascii() function returns printable representation of string containing ascii characters.
bin() The bin() function returns the binary representation of an integer.
bool() The bool() function returns boolean representation of a given value.
bytearray() The bytearray() function returns an bytearray object of a given value.
bytes() The bytes() function returns a bytes object of a given value.
callable() The callable() function returns True if a given object appears callable.
chr() The chr() function returns unicode character for integer representing the character.
classmethod() The classmethod() function returns a class method for a given function.
compile() The compile() function accepts source code and returns an executable code object. Use the exec() function to execute code block or eval() function to execute a single expression.
complex() The complex() function returns a complex number from a string or a real and imaginary part.
delattr() The delattr() function deletes an attribute from a given object. It doesn't return any value.
dict() The dict() function constructs a new dictionary.
dir() The dir() function returns a list of valid attributes for a given object.
divmod() The divmod() function returns the quotient and remainder as tuple. It accepts two numbers as arguments.
enumerate() The enumerate() function adds a counter to an iterable. It returns an enumerated object, that can be turned into a list, tuple or another iterable.
eval() The eval() function parses and runs the expression passed to it.
exec() The exec() function executes a code string or a code object.
filter() The filter() function filters elements from an iterable like a list or tuple based on a given function.
float() The float() function converts a number or string to float type.
format() The format() function returns a formatted object based on the format specification given in the second argument.
frozenset() The frozenset() function constructs a frozenset. The main difference of a frozenset is that elements are immutable.
getattr() The getattr() function returns the attribute value of a given object and attributes name.
globals() The globals() function returns the dictionary of the global symbol table. It includes all variable names, methods, classes, and so on.
hasattr() The hasattr() function checks if a given object has a specific attribute. It returns True if it has and False if not.
hash() The hash() function returns the hash value of a given object.
help() The help() function is used to access the interactive help system in the Python interpreter.
hex() The hex() function converts an integer to a hexadecimal string and returns it.
id() The id() function returns a unique identifier of an object.
input() The input() function accepts and reads input from the user.
int() The int() function converts a given input to an integer type.
isinstance() The isinstance() function checks if an object is an instance of a given class, type, or tuple of classes and types.
issubclass() The issubclass() function checks if the given class is a subclass of the second argument.
iter() The iter() function returns an iterator for a given object.
len() The len() function returns the length of an object. That is the number of items in the object.
list() The list() function constructs a new list and returns it.
locals() The locals() function returns a dictionary of all local variable names, methods, classes, and so on.
map() The map() function is used to apply a specified other function to an iterable like a list or tuple. It returns an iterable with the results of the operation.
max() The max() function returns the largest element of an iterable.
memoryview() The memoryview() function returns a memory view object a given argument.
min() The min() function returns the smallest element of an iterable.
next() The next() function returns the next item from the given iterator.
object() The object function returns a featureless object.
oct() The oct() function returns the octal representation of a given element.
open() The open() function opens a file and returns the file object.
ord() The ord() function returns an integer representing a given Unicode character. It is the reverse function of char().
pow() The pow() function returns the power of a given number.
print() The print() function prints a given object to the standard output or a file. It allows to specify the separator and end of line of the output.
property() The property() function constructs and returns the property attribute.
range() The range() function returns a sequence of numbers between given start and stop integers.
repr() The repr() function returns a printable presentation of a given object.
reversed() The reversed() function returns the reversed sequence of the given object.
round() The round() function returns the given object rounded to the specified decimal places. If the second argument is not specified, it rounds to integer values.
set() The set() function constructs and returns a set.
setattr() The setattr() function sets the attribute of an object to the given value.
slice() The slice() function returns a sliced object.
sorted() The sorted() function sorts the elements of a given object and returns a sorted list.
staticmethod() The staticmethod() function returns a static method for the given function.
str() The str() function converts a given object into a string and returns it.
sum() The sum() function returns the sum of all elements of a given object.
super() The super() function returns a proxy object, that allows access to methods of its base class.
tuple() The tuple() function constructs a tuple and returns it.
type() The type() function returns the type of a given object.
vars() The vars() function returns the __dict__ attribute of a given object.
zip() The zip() function combines iterables into a tuple and returns it.
__import__() The __import__() function is called when an import statement is executed.



Click to jump to section