Parameters and Arguments

Learn about parameters and arguments in functions.

Understanding parameters and arguments

Parameters and arguments are terms that are often used interchangeably to represent values that are provided for the function as an input. There’s a subtle difference though: the parameters of a function are set when the function is defined, whereas the arguments of a function are provided when it is called.

To see an example of a function that uses parameters, let’s create a function that squares numbers. In the example that follows, the square function accepts a single parameter, n, which is the number to be squared. In the body of the function, the name of the parameter acts just like a variable. We multiply this value by itself and return the result:

Get hands-on with 1200+ tech skills courses.