The examples didn't have any parameters defined. AppleScripts can be saved as droplets which allow users to drag and drop files or folders on a script application. You may have noticed the parentheses used when calling a subroutine. Well, not only can subroutines pass values back to the main script via parameters, but values can be passed to subroutines. Below the variables y and p are passed to the subroutine.
X is set to the result of the math that takes place in the subroutine.
The return statement is used to set the result of the subroutine to the value of x.