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

Ссылка: @Portal_v_IT

Сотрудничество: @oleginc
Download Telegram
print(any([0, "", False]))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
38%
True
60%
False
2%
None
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
26%
1
32%
2
42%
3
def modify(x, y=[]):
y.append(x)
return sum(y)

result = modify(5) + modify(7) + modify(4)
print(result)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
33%
16
61%
33
7%
21
gen = (x for x in range(3))
print(list(gen), list(gen))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
28%
[0, 1, 2] [0, 1, 2]
54%
[0, 1, 2] []
17%
TypeError
class Matrix:
def __init__(self, data):
self.data = data

def __add__(self, other):
return Matrix([[self.data[i][j] + other.data[i][j]
for j in range(len(self.data[0]))]
for i in range(len(self.data))])

def sum(self):
return sum(sum(row) for row in self.data)

m1 = Matrix([[1, 2], [3, 4]])
m2 = Matrix([[5, 6], [7, 8]])
result = m1 + m2
print(result.sum())

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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
61%
36
36%
10
3%
18
def make_counter():
count = 0
def increment():
nonlocal count
count += 1
return count
return increment

c1 = make_counter()
c2 = make_counter()
c1()
print(c1(), c2())


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
54%
2 1
34%
2 2
11%
1 1
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]
30%
[0, 2, 3, 4, 6, 8, 9]
16%
SyntaxError
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
24%
0
63%
RuntimeError
13%
KeyError
from itertools import islice

def infinite_seq():
n = 1
while True:
yield n
n *= 2

gen = infinite_seq()
result = list(islice(gen, 5))
print(sum(result))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
39%
31
39%
15
21%
32
gen = (x for x in range(3))
print(list(gen), list(gen))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
32%
[0, 1, 2] [0, 1, 2]
57%
[0, 1, 2] []
11%
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