2. Built-in Functions
See 1.6 for general information on functions.
float()
float(b)returnsbas a float object.bmay be of type str or intint()
int(b)returnsbas an integer object.bmay be of type float or str. Ifbis of type float,int(b)ignores decimal places. Ifbis of type str,bmust not have decimal places (convert to float first)len()
len(s)returns the number of elements in object s. Returns number of characters for str objects, number of elements for list objects, number of sublist for nested list objects, number of key-value pairs for dict objects.max()
max(s)returns the max value of the iterable (see 1.4.2) objects.max(a,b, ...)returns the largest value of the argumentsa, b, ...min()
min(s)returns the min value of the iterable (see 1.4.2 objects.mix(a,b, ...)returns the smallest value of the argumentsa, b, ...print() - (See section 9 for more options)
Prints objects to the screen.
range()
range(b)returns an immutable and iterable sequence of numbers from 0 tob-1.range(a,b)returns a sequence of numbers fromatob-1. Commonly used in for loops (see 6.1.)sorted()
sorted(s)returns a new sorted list from the items in the iterable (see 1.4.2 objects.str()
str(c)returns a string version of the objectc.sum()
sum(s)returns the sum of items in the iterable (see 1.4.2) objects.type()
type(c)returns the type of objectc. Knowing the type (i.e. list, dict, dataframe, etc.) tells you what methods/attributes can be called on that object.