This page is under construction.
These problems are designed to be around exam difficulty. For more basic problems, see the topic-based guides and practice problems!
What would Python print?
from operator import sub
this = lambda a, b : lambda c: a(b, c)
d = 30
def that(e, f):
if e and f:
e, d = f(sub, e)(5), e
else:
print(e)
d = 20
def this(g):
return lambda : print(g(d, e))
return this
The code above is loaded into the Python interpreter. What would the following lines output? Assume they are entered one after the other in the same environment. If there is no output, leave the space blank. If the code causes an error, write Error and describe in a few words what caused it.
>>> this(sub, d)()
Error, second function call missing an argument
>>> this(print, 40)(d)
40 30
>>> this(lambda x, y : y, d)(20)
20
>>> that(d, 0)(sub)
30
<\function ...>
>>> other = that(10, this)(print)
>>> other()
10 5
None