Function
A function is a piece of code that runs only when it is called. In fact, most if not all code in a program is contained inside functions, with code that runs continuously contained in a special function; this function is usually called 'main'. However, some languages, such as Lua, do not have a 'main' function and rely on the host program to run the functions.
Functions are generally formatted like functionName(), though this is dependent on the actual language. Functions can take parameters (usually inside parenthesis), which are used by the function to perform tasks; afterward the function may return a value. In pseudocode, this might look like:
distance(x1, y1, x2, y2) { //distance formula
dx = x2 - x1
dy = y2 - y1
dist = sqrt(dx * dx + dy * dy)
return dist
}
When a function returns, it's essentially "replaced" by its return value in the expression. Some variable assignments use functions to calculate a certain value to assign, by using this property.