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

Showing posts older than #2642 · Back to latest

Older Posts 20 shown
Post #2641 813
Что выведет код?
class User:
def __init__(self, name):
self.name = name
a = (1, User('foo'))
b = (2, User('bar'))
c = (2, User('new'))
print(a < b, b < c)
Post #2639 838
Что выведет код?
from heapq import heappush, heappop
h = []
heappush(h, (5, 'a'))
heappush(h, (7, 'b'))
heappush(h, (3, 'c'))
print(heappop(h)[1])
Post #2637 871
Что выведет код?
from heapq import heappush, heappop
def f(iterable):
h = []
for value in iterable:
heappush(h, value)
return [heappop(h) for i in range(len(h))]
print(f([3, 5, 1]))
  • 👍 1
Post #2635 843
Что выведет код?
import sys
def f(n):
if n == 0:
return 1
return n * f(n-1) # 1
sys.setrecursionlimit(1000) # 2
f(50) # 3
sys.setrecursionlimit(1) # 4
f(50) # 5
  • 👍 1
Post #2633 804
Что выведет код?
recs = [(1, 2, 3), (1, 2), (3, 4), (0, 1, 2, 3, 4)]
s = 0
for a, *b in recs:
s += sum(b)
print(s)
  • 👍 2
Post #2631 872
Что выведет код?
avg = lambda x: sum(x) / len(x)
def f(values):
a, *b, c = values
return avg(b)
f([0, 2, 3, 4])
  • 👍 1
Post #2629 919
Что выведет код?
import heapq
s = [2, 1, 3]
heapq.heapify(s)
print(s[0])
  • 👏 2
Post #2627 918
Что выведет код?
import heapq
d = [5, -2, 3, 4, 1, 7 -3, 11, -9, 0, -1, 6]
a = heapq.nsmallest(1, d)
b = heapq.nlargest(1, d)
print(*a, *b)
Post #2624 821
Что выведет код?
from collections import deque
q = deque(maxlen=3)
q.append(1)
print(q)
q.appendleft(2)
print(q)
q.append(3)
print(q)
q.append(4)
print(q)
q.popleft()
print(q.popleft())
  • 👎 2
Post #2622 810
Что выведет код?
a, b, *c, d = (1,2,3,4,5,6)
print(c)
  • 👏 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 →