Knowledge Base

2. Built-in Functions

See 1.6 for general information on functions.

  • float()

    float(b) returns b as a float object. b may be of type str or int

  • int()

    int(b) returns b as an integer object. b may be of type float or str. If b is of type float, int(b) ignores decimal places. If b is of type str, b must 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) object s. max(a,b, ...) returns the largest value of the arguments a, b, ...

  • min()

    min(s) returns the min value of the iterable (see 1.4.2 object s. mix(a,b, ...) returns the smallest value of the arguments a, 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 to b-1. range(a,b) returns a sequence of numbers from a to b-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 object s.

  • str()

    str(c) returns a string version of the object c.

  • sum()

    sum(s) returns the sum of items in the iterable (see 1.4.2) object s.

  • type()

    type(c) returns the type of object c. Knowing the type (i.e. list, dict, dataframe, etc.) tells you what methods/attributes can be called on that object.

Send Feedback
close
  • Bug
  • Improvement
  • Feature
Send Feedback
,