A basic function allows us to repeat an action. However, we often will want our functions to perform slightly different tasks each time. We can achieve these differences with function parameters.

When we define a function with parameters, we provide the function name, parameters, and code. The parameters are variables that act as inputs to the function. We can provide their values when the function is called, and access them inside of the function’s block of code.

For example, if we were writing Python program to print the average of two numbers, we could have a parameter for each number:

def print_average(num1, num2): avg = (num1 + num2) / 2 print('average of', num1, 'and', num2, 'is', avg)

The variables num1 and num2 are the function’s parameters, which are the two values the function is going to average.

We can then call this function like this:


Here, we pass the input of 10 as num1 and 12 as num2. These inputs will result in the following output:

average of 10 and 12 = 11.0

Let’s practice using parameters with functions.


Now our Move function takes in a parameter. Choose what value is passed into Move so that Codey will reach their goal.

Throughout this course we will use Blockly commands to guide Codey towards their goal. Drag the commands into the right hand box and connect them together to make a program.

For this exercise, combine the movement commands together to have Codey move onto the flag.

Codey will need to go down and to the right.
Move Right Move Right Move Down Move Down

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?