Заметки Питониста
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
27%
0
60%
RuntimeError
13%
KeyError
lst = [x for x in range(10) if x % 2 == 0 if x % 3 == 0]
print(lst)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
55%
[0, 6]
16%
[0, 2, 3, 4, 6, 8, 9]
29%
SyntaxError
class Model:
val = 1
lst = [val for _ in range(3)]

print(Model.lst)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
48%
[1, 1, 1]
30%
NameError
22%
AttributeError
x = 10
def f():
print(x)
x = 20
f()


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
43%
10
28%
20
29%
UnboundLocalError
data = [5, 10, 15, 20]
data.extend([x // 2 for x in data[:2]])
print(sum(data))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
24%
50
64%
57
12%
62
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
27%
[2]
71%
[1, 2]
2%
TypeError
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
69%
17
22%
7
9%
25
class A:
x = 1

class B(A):
pass

class C(A):
pass

B.x = 2
A.x = 3

print(C.x)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
35%
1
27%
2
37%
3
res = map(lambda x: x * 2, [1, 2])
print(list(res))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
11%
[1, 2]
83%
[2, 4]
7%
(2, 4)
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
51%
42
32%
Init 42
17%
TypeError
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