diff options
| author | Christian Kolset <christian.kolset@gmail.com> | 2025-05-06 16:25:53 -0600 |
|---|---|---|
| committer | Christian Kolset <christian.kolset@gmail.com> | 2025-05-06 16:25:53 -0600 |
| commit | e22e15fd8d9d0511a7cfa8fdb0e75509aeba6a15 (patch) | |
| tree | e3b0872f6eb82a0869992f693c3f3feba92e3afe /tutorials/module_1/functions.md | |
| parent | 98bd4cee68fb442fbbf5cd06a2e17ef31dd629f5 (diff) | |
Updated tutorials
Diffstat (limited to 'tutorials/module_1/functions.md')
| -rw-r--r-- | tutorials/module_1/functions.md | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tutorials/module_1/functions.md b/tutorials/module_1/functions.md index 54c956d..a3d291d 100644 --- a/tutorials/module_1/functions.md +++ b/tutorials/module_1/functions.md @@ -5,6 +5,7 @@ Like a traditional mathematical functions, python functions can take an input, p Functions are defined by using the <code> def </code> keyword. Reminder: it is important to keep track of indentations as it signifies the end of the function when the indentation returns back to the same level. ## Defining Functions + ### Simple function A simple function with no input variable can be useful if you need to re-use code multiple times without having to re-write it. @@ -22,6 +23,7 @@ We can pass variables through to the function to be processed as follows: ``` Note input variables can be of any data type (integer, float, string, etc.). + ### Returning values from a function If we want to calculate a value and pass it back to the script for further use, we can use the `return` keyword. Let's define a linear function that takes two inputs, `x` and `b`, computes the corresponding `y` value, and returns it so it can be used elsewhere in the code. @@ -32,6 +34,7 @@ If we want to calculate a value and pass it back to the script for further use, ``` For multiple output variables we can add + ## Calling functions Now that we've covered defining functions we want to call the function in order to execute the block inside the function. To do this, we simply re-call the function name as follows. |
