Function

Applies to: general

A function is a reusable, named piece of code that takes inputs (parameters), does something, and usually returns a value. Functions let you name an idea once and call it many times, the foundation of structured programming.

def area(width, height):   # parameters
    return width * height  # return value

a = area(3, 4)             # call -> 12

See also: variable, recursion, parameter