Заметки Питониста
14.8K subscribers
3.36K photos
17 videos
1.8K links
Все что связано с Python, уже в наших заметках.

Ссылка: @Portal_v_IT

Сотрудничество: @oleginc
Download Telegram
Варианты ответа:
Anonymous Quiz
20%
scope
23%
local
57%
global
funcs = []
for i in range(3):
funcs.append(lambda x=i: x)

print([f() for f in funcs])


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
39%
[2, 2, 2]
51%
[0, 1, 2]
10%
NameError
d = {'a': 1, 'b': 2, 'c': 3}
try:
for k in d:
del d[k]
print(len(d))
except RuntimeError:
print("RuntimeError")


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
29%
0
49%
RuntimeError
22%
KeyError
class A:
def __init__(self):
self.__x = 1

def get_x(self):
return self.__x

class B(A):
def __init__(self):
super().__init__()
self.__x = 2

b = B()
print(b.get_x())


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
31%
1
63%
2
6%
AttributeError
def f(x, y, z):
return x + y + z

d1 = {'x': 1, 'y': 2}
d2 = {'y': 3, 'z': 4}

try:
print(f(**d1, **d2))
except TypeError:
print("TypeError")


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
38%
8
32%
10
30%
TypeError
gen = (x for x in range(3))
list(gen)
print(list(gen))


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
30%
[0, 1, 2]
65%
[]
6%
TypeError
def add_item(num, lst=[]):
lst.append(num)
return lst

add_item(1)
print(add_item(2))


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
26%
[2]
72%
[1, 2]
2%
TypeError
class MockObject:
def __new__(cls):
return 42

def __init__(self):
print("Init")

obj = MockObject()
print(obj)


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
26%
Init 42
62%
42
11%
TypeError
def modify(n):
n = n + 5
n *= 2
return n

x = 10
result = modify(x) + x
print(result)


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
16%
30
80%
40
3%
50
x = [0, 1]
i = 0
i, x[i] = 1, 2
print(x)


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
48%
[2, 1]
50%
[0, 2]
2%
[2, 0]
a = [[1, 2], [3, 4]]
b = list(a)
a[0][1] = 5
print(b[0][1])


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
47%
5
43%
2
10%
IndexError
🔥1