hash, sum, super, idlen, max, min, next, sumdelattr, dir, getattr, globals, locals, setattr, varsascii, format, reprinput, open, print __import__breakpoint, @classmethod, compile, eval, exec, help, @staticmethod
Draft for Information Only
Content
Python Built-in Misc. Functions len() Parameters Remarks max() Parameters Remarks min() Parameters Remarks next() Parameters Remarks sum() Parameters Remarks Source and Reference
Python Built-in Misc. Functions
The Python interpreter has some built-in misc. functions.
len()
len(𝑠)
Parameters
len()to return the length or number of items of an object.
𝑠to specify the object to be returned from
Remarks
𝑠 may be a sequence, such as a string, bytes, tuple, list, or range, or a collection, such as a dictionary, set, or frozenset
max()
max(iterable, *[, key, default])
max(arg1, arg2, *args[, key])
Parameters
max()to return the largest item in an iterable or the largest of two or more arguments.
iterableto specify an iterable to be returned from
keyoptional, to specify a one-argument ordering function like that used for list.sort().
defaultoptional, to specify an object to return if the provided iterable is empty.
arg1to specify the first positional argument to be returned from
arg2to specify the second positional argument to be returned from
*argsto specify the third or more positional arguments to be returned from
Remarks
- If one positional argument is provided, it should be an iterable. The largest item in the iterable is returned.
- If two or more positional arguments are provided, the largest of the positional arguments is returned.
- There are two optional keyword-only arguments.
- if
key specifies a one-argument ordering function like that used for list.sort().
- if
default specifies an object to return if the provided iterable is empty
- If the
iterable is empty and default is not provided, a ValueError is raised.
- If multiple items are maximal, the functon returns the first one encountered. This is consistent with other sort-stability preserving tools, such as
sorted(iterable, key=keyfunc, reverse=True)[0] and heapq.nlargest(1, iterable, key=keyfunc)
min()
min(iterable, *[, key, default])
min(arg1, arg2, *args[, key])
Parameters
min()to return the smallest item in an iterable or the smallest of two or more arguments.
iterableto specify an iterable to be returned from
keyoptional, to specify a one-argument ordering function like that used for list.sort().
defaultoptional, to specify an object to return if the provided iterable is empty.
arg1to specify the first positional argument to be returned from
arg2to specify the second positional argument to be returned from
*argsto specify the third or more positional arguments to be returned from
Remarks
- If one positional argument is provided, it should be an iterable. The smallest item in the iterable is returned.
- If two or more positional arguments are provided, the smallest of the positional arguments is returned.
- There are two optional keyword-only arguments.
- if
key specifies a one-argument ordering function like that used for list.sort().
- if
default specifies an object to return if the provided iterable is empty
- If the
iterable is empty and default is not provided, a ValueError is raised.
- If multiple items are minimal, the functon returns the first one encountered. This is consistent with other sort-stability preserving tools, such as
sorted(iterable, key=keyfunc, reverse=True)[0] and heapq.nlargest(1, iterable, key=keyfunc)
next()
next(iterator[, default])
Parameters
next()to return the next item from the iterator.
iteratorto specify the iterator to be returned from
[default]to specify the default to be returned if the iterator is exhausted.
Remarks
- To retrieve the next item from the iterator by calling its
__next__() method.
- If
default is given, it is returned if the iterator is exhausted, otherwise StopIteration is raised.
sum()
sum(iterable, /, start=0)
Parameters
sum()to return the sum of the elements of an iterable .
iterableto specify an iterable to be returned from
/
start=0to specify the starting value
Remarks
- Sums start and the items of an iterable from left to right and returns the total. The iterable’s items are normally numbers, and the start value is not allowed to be a string.
For some use cases, there are good alternatives to sum(). The preferred, fast way to concatenate a sequence of strings is by calling ''.join(sequence). To add floating point values with extended precision, see math.fsum(). To concatenate a series of iterables, consider using itertools.chain().
Source and Reference
©sideway
ID: 201002902 Last Updated: 10/29/2020 Revision: 0
|
|