Заметки Питониста
14.7K subscribers
3.37K photos
18 videos
1.82K links
Все что связано с Python, уже в наших заметках.

Ссылка: @Portal_v_IT

Сотрудничество: @oleginc
Download Telegram
print(isinstance(True, int))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
61%
True
29%
False
11%
TypeError
class MetaCounter(type):
instances = 0

def __call__(cls, *args, **kwargs):
MetaCounter.instances += 1
return super().__call__(*args, **kwargs)

class A(metaclass=MetaCounter):
pass

class B(A):
pass

a1, a2 = A(), A()
b1 = B()
print(MetaCounter.instances)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
29%
2
65%
3
6%
5
animals = ['кот', 'собака', 'птица', 'рыба']
animals.pop(1)
animals.insert(2, 'хомяк')
print(animals[-2])


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
61%
хомяк
36%
птица
2%
рыба
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
72%
True
21%
False
8%
None
class Context:
def __enter__(self):
return "A"
def __exit__(self, *args):
return True

with Context() as c:
raise ValueError()

print(c)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
52%
A
40%
ValueError
8%
None
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
46%
2 1
34%
2 2
20%
1 1
a = [1, 2, 3]
a[1:1] = [4, 5]
print(a)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
31%
[1, 4, 5, 2, 3]
34%
[1, 4, 5, 3]
34%
[1, [4, 5], 2, 3]
data = {1: "A", True: "B"}
print(data[1])


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
37%
A
51%
B
12%
KeyError
print(round(1.5), round(2.5))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
34%
2 3
39%
1 2
27%
2 2
gen = (x for x in range(3))
a = list(gen)
b = list(gen)
print(a, b)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
37%
[0, 1, 2] [0, 1, 2]
55%
[0, 1, 2] []
7%
TypeError
x = "global"
res = [x for x in ["local", "scope"]]
print(x)


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

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