---
jupyter:
  jupytext:
    metadata_filter:
      notebook:
        additional: all
        excluded:
        - language_info
    text_representation:
      extension: .Rmd
      format_name: rmarkdown
      format_version: '1.0'
      jupytext_version: 0.8.6
  kernelspec:
    display_name: Python 3
    language: python
    name: python3
  jupyterbook:
    run: false
---

For background, please read the [functions as
values](../functions-conditionals/functions_as_values) page.

Consider these two functions:

```{python}
def add(a, b):
    return a + b
```

```{python}
def sub(a, b):
    return a - b
```

Here's `add` in action:

```{python}
add(4, 1)
```

Here's `sub` in action:

```{python}
sub(4, 1)
```

There's some code below, that will error, because the assignment
statement does not set `func` to have the value we need. Set `func`
correctly so the result equals 2:

```{python tags=c("raises-exception")}
func = add
func(10, 8)
```

Set `my_func1` and `my_func2` in the code fragment below, so that the
result is 12:

```{python tags=c("raises-exception")}
my_func1 = # Your code here
my_func2 = # Your code here
my_func1(8, 2) + my_func2(3, 3)
```

Here is a function that takes three arguments.  The first, called `f`,
should be set to a function value \- that is, a value that is the
internal representation of a function.  The second and third values, called `x` and `y`, should set to be number values.

```{python}
def do_it(f, x, y):
    return f(x, y)
```

Set `another_func` so the result returned is 4:

```{python tags=c("raises-exception")}
another_func = # Your code here
do_it(another_func, 1, 3)
```
