Learn
Functions
Parameters and Arguments

Let’s take another look at the definition of the function square from the previous exercise:

def square(n):

Here, n is a parameter of square. A parameter is a variable that is an input to a function. It says, “Later, when square is used, you’ll be able to input any value you want, but for now we’ll call that future value n.” A function can have any number of parameters.

The values of the parameters passed into a function are known as the arguments. Recall in the previous example, we called:

py square(10)

Here, the function square was called with the parameter n set to the argument 10.

Typically, when you call a function, you should pass in the same number of arguments as there are parameters.

To summarize:

  • When defining a function, placeholder variables are called parameters.
  • When using, or calling, a function, inputs into the function are called arguments.

Instructions

1.

Check out the function in the editor, power. It should take two arguments, a base and an exponent, and raise the first to the power of the second. It’s currently broken, however, because its parameters are missing.

Replace the ___s with the parameters base and exponent and then call the power function with a base of 37 and an exponent of 4.

Folder Icon

Take this course for free

Already have an account?