Python Built-in Functions
abs(x)
Returns the absolute value of a number.
all(iterable)
Checks if all elements of iterable are true. Returns True if all elements are true or if the iterable is empty.
any(iterable)
Checks if there is at least one true element in iterable.
ascii(object)
Replaces non-printable characters in object with their ASCII representation and returns it.
bin(x)
Converts an integer x to a binary string. If x is not an int, it must define an __index__() method that returns an integer.
bool(x=False)
Converts to bool type using standard truth-testing.
bytearray(source=b'')
bytearray(source, encoding)
bytearray(source, encoding, errors)
Returns a bytearray object, which is an array of bytes.
bytes([source[, encoding[, errors]]])
Returns a byte array. The bytes type is an immutable sequence of integers in the range 0 ≤ X < 256. Use source for initial array initialization.
callable(obj)
Returns True if obj is callable, otherwise False.
chr(i)
Returns the character for the given numeric representation. i must be a positive integer.
classmethod(function)
Represents function as a class method. A class method implicitly receives the class as its first argument, similar to how an instance method receives the instance.
compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)
Compiles source code into a code object or an abstract syntax tree (AST) object. The code object can be executed using eval or exec.
complex([real[, imag]])
Returns a complex number with the value real + imag * 1j or converts a string to a complex number if the first argument is a string.
delattr(object, name)
Deletes the attribute name from object. The attribute will be deleted if the object supports this action.
dir()
dir(object)
Returns the attributes of object in alphabetical order. When called without an argument, it returns the names of variables available in the local scope.
dict(**kwargs)
dict(mapping, **kwargs)
dict(iterable, **kwargs)
Creates a dictionary in Python.
divmod(a, b)
Takes two numbers as arguments and returns their quotient and remainder as a tuple.
enumerate(sequence, start=0)
Returns an iterator that yields pairs of counter-element for elements in sequence. Set the initial value of the counter with start.
eval(expression, globals=None, locals=None)
Parses and executes the expression passed to it.
exec(object, globals=None, locals=None, /, *, closure=None)
Dynamically executes the code object.
filter(function, iterable)
Filters elements of iterable using the specified function.
format(value, format_spec='')
Formats the specified value.
frozenset([iterable])
Returns an immutable set.
getattr(object, name)
getattr(object, name, default)
Returns the value of the named attribute of an object. If not found, returns the default value provided.
globals()
Returns a dictionary of the global symbol table defined in a module.
hasattr(object, name)
Returns True if object has the specified named attribute, otherwise False.
hash(object)
Returns the hash of the specified object.
hex(x)
Converts an integer to its corresponding hexadecimal string.
id(object)
Returns the identifier of the specified object.
input()
input(prompt)
Reads and returns a string of input data.
int(x=0)
int(x, base=10)
Converts x to an integer in the decimal system. Any base from 2 to 36 inclusive can be specified.
__import__(name, globals=None, locals=None, fromlist=(), level=0)
Function called by the import statement.
iter(object)
iter(object, sentinel)
Returns an iterator object.
isinstance(object, classinfo)
Checks if an object is an instance or subclass of a class classinfo.
issubclass(class, classinfo)
Returns whether the specified class is a subclass of classinfo.
len(s)
Returns the number of elements in the specified container.
list
list(iterable)
Creates a list.
locals()
Returns a dictionary representing the current local symbol table.
map(function, iterable, *iterables)
Applies the specified function to each element of the specified sequence (s).
max(iterable, *, key=None)
max(iterable, *, default, key=None)
max(arg1, arg2, *args, key=None)
Returns the element with the highest value from those passed to the function.
memoryview(object)
Returns a memory view object for the given argument.
min(iterable, *, key=None)
min(iterable, *, default, key=None)
min(arg1, arg2, *args, key=None)
Returns the element with the lowest value from those passed to the function.
next(iterator)
next(iterator, default)
Returns the next element of the iterator.
object()
Returns a featureless object that is the base for all objects.
open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
Opens a file and returns a corresponding file object.
ord(c)
Returns the numeric representation for the specified character.
pow(base, exp, mod=None)
Returns the result of raising a number to a power, with optional modulus division.
print(*objects, sep=' ', end='\n', file=None, flush=False)
Prints the specified objects to the screen or sends them as a text stream to a file.
property(fget=None, fset=None, fdel=None, doc=None)
Returns a property attribute.
range(stop)
range(start, stop, step=1)
An arithmetic progression from start to stop with a step of step.
repr(object)
Returns a formal string representation of the specified object.
reversed(seq)
Returns a reverse iterator over the specified sequence seq.
round(number, ndigits=None)
Returns a floating-point number rounded to the specified number of decimal places.
set
set(iterable)
Creates a set.
setattr(object, name, value)
Adds the specified attribute to an object.
sorted(iterable, *, key=None, reverse=False)
Returns a new sorted list from the elements of the iterable.
str(object='')
str(object=b'', encoding='utf-8', errors='strict')
Returns a string representation of an object.
vars()
vars(object)
Returns the dictionary of the dict attribute of the specified object.
zip(*iterables, strict=False)
Returns an iterator of tuples, where the i-th tuple contains the i-th element from each of the specified sequences.