Python Built-in Functions

The Python interpreter has a number of functions and types built into it that are always available. The Python built- in functions are as follow:

Methods Explaining
abs() The abs() function returns the absolute value of a number
all() The all() function returns True if all items in an iterable object are true.
any() The any() function returns True if any item in an iterable object is true
ascii() This function returns a readable version of an object.
bin() The bin() function convert an integer number to a binary string prefixed with “0b”.
bool() The bool()class returns the boolean value for the given object
bytearray() The bytearray()class returns an array of bytes
bytes() The byte()class returns a bytes object.
chr() The chr() function returns a character from the specified Unicode code.
compile() This function returns the specified source as an object, ready to be executed
complex() This function returns a complex number
delattr() The delattr() function deletes the specified attribute (property or method) from the specified object
dict() The dict() function returns a dictionary (Array)
dir() This function returns the list of names in the current local scope
divmod() The divmod() function returns the quotient and the remainder when argument1 is divided by argument2.
enumerate() The enumerate() function returns an enumerate object.
eval() The eval() function evaluates and executes an expression.
filter() The filter() function constructs an iterator from those elements of iterable for which function returns true.
float() This class returns a floating point number constructed from a number or string x.
format() This function Formats the specified value.
frozenset() The frozenset() function returns a frozenset object
getattr() This function returns the value of the named attribute of object.
globals() The globals() function returns a dictionary representing the current global symbol table.
hasattr() The hasattr() function returns True if the specified object has the specified attribute (property/method)
hash() The hash() function returns the hash value of the object. 
hex() This function converts an integer number to a lowercase hexadecimal string prefixed with “0x”.
id() The id() function returns the “identity” of an object.
input() The input() function reads a line from input, converts it to a string and returns that string.
int() The int() function returns an integer object constructed from a number or string x, or return 0 if no arguments are given.
isinstance() This function returns a boolean value true if the object argument is an instance of the classinfo argument, or of a subclass thereof.
issubclass() The issubclass() returns a boolean value true if class is a subclass (direct, indirect or virtual) of classinfo.
iter() This function returns an iterator object.
len() The len() function returns the length (the number of items) of an object.
list() This list() function returns a list.
locals() The locals() updates and returns a dictionary representing the current local symbol table.
map() This function returns the given iterator with the specified function applied to each item.
max() The max()returns the largest item in an iterable or the largest of two or more arguments.
memoryview() This function returns a “memory view” object created from the given argument.
min() The min() function returns the smallest item in an iterable or the smallest of two or more arguments.
next() The next()function returns the next item in an iterable
object() The object()function returns a new object
oct() The oct() function converts a number into an octal
open() This function opens a file and returns a file object
ord() This function converts an integer representing the Unicode of the specified character
pow() The pow()function returns x to the power y; if z is present, return x to the power y, modulo z
print() This function prints objects to the text stream file.
property() The property() function returns a property attribute.
range() The range()function returns a sequence of numbers, starting from 0 and increments by 1 (by default)
repr() This function returns a string containing a printable representation of an object.
reversed() The reversed() function returns a reverse iterator. 
round() The round() function returns the number by rounding to ndigits precision after the decimal point.
set() The set() function returns a new set object, optionally with elements taken from iterable.
setattr() This function sets an attribute (property/method) of an object.
slice() The slice() function returns a slice object.
sorted() This function returns a new sorted list from the items in iterable.
str() The str() function returns a str version of object.
sum() This function sums the items of the specified iterator
tuple() The tuple() function returns a tuple
type() The type() function returns the type of an object.
vars() This function returns the __dict__ property of an object.
zip() This function returns an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables.

Example 1


Example 2


Example 3


Pin It on Pinterest

Share This