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

Ссылка: @Portal_v_IT

Сотрудничество: @oleginc
Download Telegram
Варианты ответа:
Anonymous Quiz
54%
42
28%
Init 42
18%
TypeError
class Point:
__slots__ = ['x', 'y']

p = Point()
p.x = 1
p.z = 2
print(p.x)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
33%
1
28%
None
40%
AttributeError
def add_item(val, target=[]):
target.append(val)
return target

print(add_item(1), add_item(2))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
👍1
Варианты ответа:
Anonymous Quiz
48%
[1] [1, 2]
26%
[1] [2]
26%
[1, 2] [1, 2]
colors = ['red', 'green', 'blue']
colors.insert(1, colors.pop())
colors.reverse()
print(colors[0])


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
36%
red
42%
green
23%
blue
d = {'a': 1, 'b': 2}
try:
for k in d:
del d[k]
print("Done")
except RuntimeError:
print("Error")


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
33%
Done
56%
Error
12%
KeyError
from collections import defaultdict

class Tree(defaultdict):
def __init__(self):
super().__init__(Tree)

t = Tree()
t['a']['b']['c'] = 10
t['a']['b']['d'] = 20
t['a']['e'] = 5

def count_leaves(d):
total = 0
for v in d.values():
if isinstance(v, dict):
total += count_leaves(v)
else:
total += v
return total

print(count_leaves(t))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
41%
30
56%
35
3%
25
👩‍💻 Хватит учить только синтаксис, начинай делать реальные проекты!

Python Ready — авторский канал, где Python перестаёт быть только теорией и становится рабочим инструментом. Мини-проекты, боты, советы, разборы задач, гайды и шпаргалки для каждого программиста.

🔥 Советую подписаться: @python_ready
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
a = 256
b = 256
c = 257
d = 257
print(a is b, c is d)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
29%
True True
52%
True False
20%
False False
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
24%
8
38%
10
38%
TypeError