diff --git a/code-workflow-logic/python-functions-multi-parameters.md b/code-workflow-logic/python-functions-multi-parameters.md index da07081..01ec312 100644 --- a/code-workflow-logic/python-functions-multi-parameters.md +++ b/code-workflow-logic/python-functions-multi-parameters.md @@ -20,32 +20,37 @@ jupyter: (multi-parameter-functions)= # Write Multi-Parameter Functions -##Learning Objectives +:::{admonition} What you will learn +:class: tip * Write and execute custom functions with multiple input parameters in **Python**. -* Write and execute custom functions with optional input parameters in **Python**. +* Write and execute custom functions with optional input parameters in **Python**. +::: ## How to Define a Function with Multiple Parameters in Python -Previously in this lesson, you learned that an input parameter is the required information that you pass to the function for it to run successfully. The function will take the value or object provided as the input parameter and use it to perform some task. - -You also learned that in **Python**, the required parameter can be defined using a placeholder variable, such as `data`, which represents the value or object that will be acted upon in the function. - +In the [write functions lesson](write-python-functions), you learned about writing **Python** functions. You also learned that a parameter, such as `var_a`, is used to represent the value or object that the function will process. + ```python -def function_name(data): -``` +def process_value(value): + """A function that returns an integer value multiplied by 2 """ + return int(value) * 2 -However, sometimes you may need additional information for the function to run successfully. +process_value(2.254) +``` -Luckily, you can write functions that take in more than one parameter by defining as many parameters as needed, for example: +However, sometimes, you need additional parameters for the function to run successfully. Like this: ```python def function_name(data_1, data_2): -``` + # Function code here + return some_output +``` -When the function is called, a user can provide any value for `data_1` or `data_2` that the function can take as an input for that parameter (e.g. single value variable, list, **numpy** array, **pandas** dataframe column). + +When the function is called, a user can provide any value for `data_1` or `data_2` that the function can take as input for that parameter (e.g., single-value variable, list, **numpy** array, **pandas** data frame column). ## Write a Function with Multiple Parameters in Python @@ -54,8 +59,7 @@ Imagine that you want to define a function that will take in two numeric values Begin with the `def` keyword and the function name, just as you have before to define a function: -```python -def multiply_values + ``` Next, provide two placeholder variable names for the input parameters, as shown below. @@ -532,9 +536,8 @@ precip_2002_2013_df ``` -