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

Ссылка: @Portal_v_IT

Сотрудничество: @oleginc
Download Telegram
Варианты ответа:
Anonymous Quiz
26%
4
58%
2
16%
TypeError
d = {'a': 1}
print(d.setdefault('a', 2), d.setdefault('b', 3))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
31%
2 3
48%
1 3
21%
KeyError
❤1
d = dict.fromkeys(['x', 'y'], [])
d['x'].append(1)
print(d['y'])


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
33%
[]
60%
[1]
7%
KeyError
lst = [[1, 2], [3, 4]]
print(sum(lst, []))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
d = {True: 'a', 1: 'b', False: 'c', 0: 'd'}
print(len(d))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
32%
4
55%
2
13%
TypeError
text = "A  B"
print(len(text.split()), len(text.split(" ")))


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
44%
2 2
47%
2 3
10%
3 3
def my_func():
return "Hello"

my_func.custom_attr = 5
print(my_func.custom_attr)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
53%
5
42%
AttributeError
5%
SyntaxError
class MetaClass(type):
def __new__(cls, name, bases, dct):
dct['meta_value'] = 100
return super().__new__(cls, name, bases, dct)

def __init__(cls, name, bases, dct):
cls.meta_value += len(name)

class A(metaclass=MetaClass):
pass

class B(metaclass=MetaClass):
pass

print(A.meta_value + B.meta_value)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
46%
200
37%
201
17%
203
t = (1, 2, [3, 4])
t[2].append(5)
print(t)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
73%
(1, 2, [3, 4, 5])
21%
TypeError
6%
(1, 2, [3, 4])
data = {"x": 10, "y": 20}
a, b = data
print(a, b)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
46%
x y
31%
10 20
23%
('x', 10) ('y', 20)
def increment(x):
x += 10
return x

value = 5
new_value = increment(value)
print(value + new_value)


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

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
79%
20
17%
25
4%
15