What will this code do?
def maker(n, h=lambda: 3):
return lambda f=h: f()**n, lambda f=h: n**f()
f, g = maker(2)
r = f(g) + g(f)
print(r)
Choose your answer
Anonymous Quiz
9%
5
36%
17
0%
31
9%
72
9%
73
0%
128
18%
576
0%
19699
18%
See solution
What will this code do?
funcs = [lambda x: x**i for i in range(2, 4)]
print(funcs[0](5))
Choose your answer
Anonymous Quiz
16%
5
32%
25
11%
[25]
16%
125
21%
[25, 125]
0%
625
5%
See solution
What will this code do?
def f():
def g():
nonlocal x
x = 2
g()
print(x)
f()
👍1
👍1
What will this code do?
def f(name="", value=0):
import sys
func_name = sys._getframe(0).f_code.co_name
func = sys._getframe(1).f_locals[func_name]
setattr(func, name, value)
return sum(func.__dict__.values())
print(f("x", 1), f("y", 2), f())
Choose your answer
Anonymous Quiz
20%
1 1 1
0%
1 2 2
0%
1 2 3
40%
1 3 3
10%
1 2 None
0%
3 3 3
30%
See solution
Choose your answer
Anonymous Quiz
22%
1 2
9%
10 2
30%
10 1 2
4%
None 2
30%
TypeError
4%
See solution
What will this code do?
def f():
x = 1
def g():
x += 1
g()
print(x)
print(f())
Choose your answer
Anonymous Quiz
26%
1
26%
2
11%
None
16%
SyntaxError
21%
UnboundLocalError
0%
See solution
What will this code do?
def func(а, b):
а = 2
b = b[:]
b[0] = 10
a, b = [0], [1]
func(a, b)
print(a, b)
Choose your answer
Anonymous Quiz
0%
[0] [10]
0%
0 10
29%
[0] [1]
6%
0 1
12%
[2] [10]
0%
2 10
18%
[2] [1]
29%
2 [1]
6%
See solution
What will this code do?
def func(а, b):
а[0] = 2
b = b[:]
b[0] = 10
a, b = [0], [1]
func(a, b)
print(a, b)
Choose your answer
Anonymous Quiz
0%
[0] [10]
0%
0 10
27%
[0] [1]
0%
0 1
27%
[2] [10]
7%
2 10
40%
[2] [1]
0%
2 [1]
0%
See solution