Note: I am not an official teacher or GSI for any of the courses listed on this site unless otherwise stated. Any problems and notes are created from my own observations and may not accurately reflect the course's content.

Higher Order Functions #2

For each of the expressions in the table below, write the output displayed by the interactive Python interpreter when the expression is evaluated. The output may have multiple lines. Expressions evaluated by the interpreter have a cumulative effect.

If an error occurs, write "Error", but include all output displayed before the error. If evaluation would run forever, write "Forever". To display a function value, write "Function".

Assume that you have started python3 and executed the statements above.

Problem A

smasher(15, 10)

Solution to Problem A

Problem B

print(print(puncher(3, 11)), None)

Solution to Problem B

Problem C

squeezer(lambda x: 2 * x + 5)()

Solution to Problem C

Problem D

life(smasher)()()

Solution to Problem D

Problem E

life(print)()

Solution to Problem E

Have a question? Found an error? Email me at imran.khaliq@berkeley.edu with the URL of the page and a short description.