For background, please read the functions as values page.

Consider these two functions:

def add(a, b):
    return a + b
def sub(a, b):
    return a - b

Here’s add in action:

add(4, 1)
5

Here’s sub in action:

sub(4, 1)
3

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:

func = add
func(10, 8)
18

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

my_func1 = # Your code here
my_func2 = # Your code here
my_func1(8, 2) + my_func2(3, 3)
  File "/var/folders/_7/h5j1wn6n2b5c2qwh5dtr3jlm0000gq/T/ipykernel_20822/117259866.py", line 1
    my_func1 = # Your code here
               ^
SyntaxError: invalid syntax

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.

def do_it(f, x, y):
    return f(x, y)

Set another_func so the result returned is 4:

another_func = # Your code here
do_it(another_func, 1, 3)
  File "/var/folders/_7/h5j1wn6n2b5c2qwh5dtr3jlm0000gq/T/ipykernel_20822/3126590280.py", line 1
    another_func = # Your code here
                   ^
SyntaxError: invalid syntax