Here is how to define a Mathematica function that adds two numbers.
Arguments for the function are specified using pattern _ indicators. The delayed assignment := operator indicates that the body of the function is evaluated only once the values for the arguments are known.
The next example uses a function defined in a standard package, which you must load first.
This is an example of a function that generates a graphic.
The function triangulates a set of n random coordinates.
Here is a version of the same function, written in two steps.
In this definition, a local variable is defined within the body of the function. The two steps within the body of the function are separated using a semicolon. The final line of code returns the value of the function.