TGViewer
Channel Public Channel
Python Tasks & ML | Задачи по питону и машинному обучению

Python Tasks & ML | Задачи по питону и машинному обучению

@python_tasks

Algorithms, functions, classes, regular expressions, iterators, generators, OOP, exceptions, NumPy, pandas, scikit-learn
https://telega.in/c/python_tasks

Questions — @dina_ladnyuk
Subscribers
8.49K
Photos
30
Videos
1
Links
41

Showing posts older than #1197 · Back to latest

Older Posts 20 shown
Post #1196 2.7K
Что выведет код?
from fnmatch import fnmatchcase
l = [f'{b}{a}' for a in range(20) for b in ['x', 'y']]
r = [x for x in l if fnmatchcase(x, 'x*0')]
print(*r)
  • 👍 1
Post #1194 2.71K
Что выведет код?
from fnmatch import fnmatch
n = "foo2022.txt"
x = fnmatch(n, "foo[0-9]*")
y = fnmatch(n, "foo[0-9]+")
print(x, y)
Post #1192 2.8K
Что выведет код?
import re
line = "a+b"
x = re.split(r"(\+)", line)
y = re.split(r"\+", line)
z = re.split(r"(?:\+)", line)
p = set(x) - set(y) | set(z)
print(len(p))
Post #1187 2.77K
Что выведет код?
from collections import ChainMap
a = {'x': 1, 'z': 3 }
b = {'y': 2, 'z': 4 }
c = ChainMap(a, b)
a['x'] = 10
c['y'] = 20
c['z'] = 30
print(c['x'], b['y'], a['z'], b['z'])
Post #1183 2.48K
Что выведет код?
from collections import ChainMap
values = ChainMap()
values['x'] = 1
values = values.new_child()
values['x'] = 2
values = values.parents
print(values['x'])
Post #1180 2.57K
Что выведет код?
from collections import ChainMap
a = {'x': 1}
b = {'x': 2}
c = {'x': 3}
d = ChainMap(a, b, c)
del d['x']
del d['x']
print(d['x'])
Post #1178 2.63K
Что выведет код?
from collections import ChainMap
a = {'x': 1, 'z': 3 }
b = {'y': 2, 'z': 4 }
c = ChainMap(a,b)
c['z'] = 10
c['w'] = 40
del c['x']
print(sum(a.values()), sum(b.values()))
Post #1175 2.8K
Что выведет код?
from collections import ChainMap
d1 = {'x': 1, 'z': 10}
d2 = {'y': 2, 'z': 20}
d3 = {**d1, **d2}
d4 = ChainMap(d1, d2)
s1 = d3['x'] + d3['y'] + d3['z']
s2 = d4['x'] + d4['y'] + d4['z']
print(s1, s2)
Post #1173 2.74K
Что выведет код?
from collections import ChainMap
a = {'x': 1, 'z': 3 }
b = {'y': 2, 'z': 4 }
c = ChainMap(a,b)
print(c['x'] + c['y'] - c['z'])
Post #1171 2.81K
Что выведет код?
from operator import itemgetter
ds = [{"x": 1}, {"x": 2, "y": 3}]
min1 = min(ds, key=itemgetter('x'))
min2 = min(i['x'] for i in ds)
print(min1 == min2)
Older posts →
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →