summaryrefslogtreecommitdiff
path: root/tutorials/module_1/functions.md
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials/module_1/functions.md')
-rw-r--r--tutorials/module_1/functions.md3
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.