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

Ссылка: @Portal_v_IT

Сотрудничество: @oleginc
Download Telegram
Варианты ответа:
Anonymous Quiz
58%
[1, 1, 1]
30%
NameError
12%
AttributeError
data = {}
data.setdefault("keys", []).append(1)
data.setdefault("keys", []).append(2)
print(data["keys"])


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
54%
[1, 2]
41%
[2]
5%
TypeError
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
27%
1
31%
2
42%
3
This media is not supported in your browser
VIEW IN TELEGRAM
👩‍💻 Всем программистам посвящается!

Вот 14 авторских обучающих IT каналов по самым востребованным областям программирования:

Выбирай своё направление:

👩‍💻 Python — t.me/python_ready
🤔 InfoSec & Хакинг — t.me/hacking_ready
🖥 SQL & Базы Данных — t.me/sql_ready
👩‍💻 IT Новости — t.me/it_ready
🤖 AI & ML — t.me/neuro_ready
👩‍💻 Frontend — t.me/frontend_ready
👩‍💻 C/C++ — https://t.me/cpp_ready
👩‍💻 C# & Unity — t.me/csharp_ready
👩‍💻 Linux — t.me/linux_ready
👩‍💻 Java — t.me/java_ready
📖 IT Книги — t.me/books_ready
📱 JavaScript — t.me/javascript_ready
🖼️ DevOps — t.me/devops_ready
🖥 Design —t.me/design_ready

📌 Гайды, шпаргалки, задачи, ресурсы и фишки для каждого языка программирования!
Please open Telegram to view this post
VIEW IN TELEGRAM
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
43%
2 1
39%
2 2
17%
1 1
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
18%
30
78%
35
4%
25
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
👍1
Варианты ответа:
Anonymous Quiz
26%
0
62%
RuntimeError
12%
KeyError
gen = (x for x in range(5))
print(2 in gen, 2 in gen)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
31%
True True
67%
True False
2%
False False
tpl = ([],)
tpl[0].extend([1, 2])
print(tpl)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
67%
([1, 2],)
25%
([],)
8%
TypeError
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
35%
True True
46%
True False
19%
False False
🔥1
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
31%
[0, 1, 2] [0, 1, 2]
63%
[0, 1, 2] []
6%
TypeError
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