Useful Built-in Functions
round(): The
round()
function is used to round a number to a specified number of decimal places.
It takes one required argument, the number to be rounded, and an optional argument that specifies the number of decimal places (default is 0). The function returns a floating-point number.
chr(): The
chr()
function returns a string representing a character whose Unicode code point is the specified integer.
It takes an integer argument and returns the corresponding character.
ord(): The
ord()
function returns an integer representing the Unicode character.
It takes a single character as an argument and returns the Unicode code point of that character.
len(): The
len()
function is used to determine the length or size of an object.
It returns the number of items in an object such as a string, list, tuple, or dictionary.
min(): The
min()
function is used to find the minimum value among the given arguments or an iterable object.
It can be used with numbers, strings, or other comparable objects.
The min()
function can also take multiple arguments separated by a comma to determine the minimum value from variables or multiple data objects.
max(): The
max()
function is used to find the maximum value among the given arguments or an iterable object.
It works similarly to min()
but returns the maximum value instead. max()
can also take multiple arguments as well.
sum(): The
sum()
function is used to calculate the sum of all elements in an /sequence, such as a list or tuple.
It takes an iterable as an argument and returns the sum of its elements. The items of each iterable must be addable.
These are some of the commonly used functions in Python that perform specific operations, such as rounding, character conversions, length calculation, finding minimum and maximum values, and summing elements.
Last updated