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

Ссылка: @Portal_v_IT

Сотрудничество: @oleginc
Download Telegram
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
21%
0
65%
RuntimeError
14%
KeyError
tpl = ([],)
tpl[0].extend([1, 2])
print(tpl)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
71%
([1, 2],)
20%
([],)
10%
TypeError
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
31%
[2, 1]
57%
[0, 2]
12%
[2, 0]
def calculate(x, y):
if x > y:
return x - y
else:
return y - x

result = calculate(10, 15) + calculate(20, 8)
print(result)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
64%
17
27%
7
9%
25
def increment(x):
x += 10
return x

value = 5
new_value = increment(value)
print(value + new_value)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
63%
20
25%
25
13%
15
class A:
def __new__(cls):
return 42

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

print(A())


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
47%
42
40%
Init 42
14%
TypeError
data = {'a': [1, 2], 'b': [3, 4]}
data['c'] = data['a'] + data['b']
data['a'].append(5)
print(len(data['c']))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
48%
4
50%
5
2%
6
funcs = [lambda: i for i in range(3)]
print(funcs[0](), funcs[-1]())


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
52%
0 2
33%
2 2
15%
NameError
class A: pass
class B(A): pass
class C(A): pass
class D(B, C): pass
print(D.mro()[1].__name__)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
36%
А
38%
B
27%
C
d = {1: "A", True: "B", 1.0: "C"}
print(len(d), d[1])


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:ё
Anonymous Quiz
30%
3 C
52%
1 C
18%
1 A
print(any([0, "", False]))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM