Learn

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:

``print_average(10,12)``

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.

### Instructions

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.

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