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.5K
Photos
30
Videos
1
Links
41

Showing posts older than #2262 · Back to latest

Older Posts 20 shown
Post #2261 1.45K
Что выведет код?
line = 'aaa bbb ccc d e f'
g1 = ''.join(x.upper() for x in line.split() if len(x) > 1)
def gen(line):
for x in line.split():
if len (x) > 1:
yield x.upper()
g2 = ''.join(gen(line))
print(g1 == g2)
Post #2259 1.34K
Что выведет код?
def f(n):
yield from range(n)
yield from (x ** 2 for x in range(n))
res = ':'.join(str(i) for i in f(3))
print(res)
Post #2257 1.22K
Что выведет код?
G = (с for с in '123')  
I1 = iter(G)
I2 = iter(G)
_ = next(I1)
_ = next(I1)
print(next(I2))
Post #2255 1.31K
Что выведет код?
g1 = (c * 2 for c in 'ABC')
def gen(m):
for c in m:
yield c * 2
g2 = gen('ABC')
print(list(g1) == list(g2))
Post #2253 1.23K
Что выведет код?
def f(arr):
return 0 if not arr else arr[0] + f(arr[2:])
print(f([3, 3, 3]))
Post #2251 1.32K
Что выведет код?
funcs = [lambda x: x**i for i in range(2, 4)]
print(funcs[0](5))
Post #2249 1.25K
Что выведет код?
def maker(n, h=lambda: 3):
return lambda f=h: f()**n, lambda f=h: n**f()
f, g = maker(2)
r = f(g) + g(f)
print(r)
Post #2247 1.19K
Что выведет код?
f = lambda x, f=lambda x: x**2:  f(x)
print(f(5), f(5, f))
Post #2245 1.26K
Что выведет код?
def maker(n):
s = 0
def g(x=n):
nonlocal s
s += x
return s
return lambda x: s + x + g()
f = maker(2)
print(f(3), f(3))
  • 👍 1
Post #2243 1.29K
Даны два модуля testmod.py и runmod.py
#testmod.py
x = 0
def f1():
x = 10
def f2():
global x
x += 1
def f3():
import testmod
testmod.x += 1
def f4():
import sys
sys.modules["testmod"].x += 1

#runmod.py
import testmod as t
t.f1();t.f2();t.f3();t.f4()
print(t.x)
  • 👍 4
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 →