Choose the correct answer
Anonymous Quiz
6%
1 2 1 1
24%
1 2 2 1
71%
1 2 2 2
0%
1 2 1 2
0%
2 2 2 2
0%
See solution
Two modules are given testmod.py and runmod.py
#testmod.py
x = 0
def f1():
x = 10
def f2():
global x
x += 1
def f3():
import testmod
testmod.x += 1
def f4():
import sys
sys.modules["testmod"].x += 1
#runmod.py
import testmod as t
t.f1();t.f2();t.f3();t.f4()
print(t.x)
The entry point into the program is a module runmod.py. What will be the conclusion?
Anonymous Quiz
0%
0
11%
1
22%
2
44%
3
11%
10
11%
11
0%
12
0%
13
0%
See solution
What will this code do?
def maker(n):
s = 0
def g(x=n):
nonlocal s
s += x
return s
return lambda x: s + x + g()
f = maker(2)
print(f(3), f(3))androidWhat will this code do?
f = lambda x, f=lambda x: x**2: f(x)
print(f(5), f(5, f))Choose the correct answer
Anonymous Quiz
0%
5 5
8%
5 (5, 5)
15%
5 25
0%
5 125
15%
5 (25, 25)
38%
25 25
15%
25 125
0%
125 125
8%
5 (125, 125)
0%
See solution
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)
❤1
Choose the right option
Anonymous Quiz
10%
5
30%
17
30%
31
0%
72
0%
73
10%
128
20%
576
0%
19699
0%
See solution
What will this code do?
funcs = [lambda x: x**i for i in range(2, 4)]
print(funcs[0](5))
Choose the correct answer
Anonymous Quiz
0%
5
44%
25
19%
[25]
13%
125
13%
[25, 125]
13%
625
0%
See solution
What will this code do?
def f():
def g():
nonlocal x
x = 2
g()
print(x)
f()
Choose the correct answer
Anonymous Quiz
41%
2
12%
None
18%
SyntaxError
24%
NameError
6%
See solution
📣 Внимание, друзья! 📣
Рады объявить о запуске нового телеграм-канала - HikingEscapades!
💥Мы будем регулярно делиться с вами новыми маршрутами для хайкинга, чтобы вдохновить вас на увлекательные путешествия и незабываемые приключения на природе!
⏰ Два раза в месяц по средам в 9 утра будем выкладывать новый маршрут с подробным описанием и фотографиями.
Подписывайтесь на телеграм канал HikingEscapades!
Оставляйте ваши комментарии, делитесь впечатлениями от маршрутов и советуйте друзьям.
Рады объявить о запуске нового телеграм-канала - HikingEscapades!
💥Мы будем регулярно делиться с вами новыми маршрутами для хайкинга, чтобы вдохновить вас на увлекательные путешествия и незабываемые приключения на природе!
⏰ Два раза в месяц по средам в 9 утра будем выкладывать новый маршрут с подробным описанием и фотографиями.
Подписывайтесь на телеграм канал HikingEscapades!
Оставляйте ваши комментарии, делитесь впечатлениями от маршрутов и советуйте друзьям.
What will this code do?
def f():
def g():
global x
x = 2
g()
print(x)
f()
Choose the correct answer
Anonymous Quiz
37%
2
0%
None
37%
SyntaxError
21%
NameError
5%
See solution
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 the correct answer
Anonymous Quiz
20%
1 1 1
20%
1 2 2
30%
1 2 3
20%
1 3 3
10%
1 2 None
0%
3 3 3
0%
See solution
Choose the correct answer
Anonymous Quiz
20%
1 2
24%
10 2
16%
10 1 2
4%
None 2
32%
TypeError
4%
See solution