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 #1540 · Back to latest

Older Posts 20 shown
Post #1539 2.33K
Что выведет код?
def f():
x = 1
y = 1
def g():
nonlocal x
x, y = 2, 2
g()
print(x, y)

f()
  • 👍 6
Post #1538 2.57K
  • 👍 10
Post #1537 2.38K
Что выведет код?
def f(n):
return 0 if n == 0 else 2**n + f(n-1)
print(f(3))
  • 👍 3
Post #1536 3.01K
  • 👨‍💻 5
  • 💯 2
  • 👍 1
  • 🤔 1
Post #1535 2.73K
Что выведет код?
def intersect(*seqs):
if len(seqs) > 2:
return intersect(seqs[0], intersect(*seqs[1:]))
seq1, seq2 = seqs[0], seqs[1]
res = []
for x in seq1:
if x in seq2:
res.append(x)
return res

x = intersect([1, 2, "a", "b"], (1, 4, "b"), {1, "b", "c"})
print(x)
Post #1534 2.86K
  • 😱 4
  • 👍 3
Post #1533 2.47K
Что выведет код?
class A:
__x = 1
def f(self):
return "f from A"

def g(self):
return "g from A"

class B:
__x = 2
def f(self):
return "f from B"

def g(self):
return "g from B"

class C(A, B):
f = B.f

c = C()
print(c.f(), c.g(), c._A__x, c._B__x)
Post #1532 2.51K
  • 😱 26
  • 🤬 3
  • 👍 1
  • 🤔 1
Post #1531 2.33K
Дан код
class A:
__x = 1

a = A()
Post #1530 2.57K
  • 👍 4
  • 🤔 4
Post #1529 2.43K
Что выведет код?
def f():
setattr(f, "x", getattr(f, "x", 0) + 1)
f.f = f
return f
x = f()()().f.f.f().f.x
print(x)
  • 👍 2
Post #1525 2.55K
Что выведет код?
class C:
listing = []

x = C()
x.listing.append(1)
x.listing.append(1)
x.listing = 1
print(x.listing, C.listing)
Post #1522 2.82K
Дан код:
d = {}
d[2, 3] = "a", "b"
Post #1521 3.08K
  • 👍 6
  • 🤔 1
Post #1520 2.78K
Что выведет код?
class A:
x = 1
l = []
a1, a2 = A(), A()
a1.x = 2
a1.l.append(100)
print(a2.x, len(a2.l))
Post #1517 2.57K
Что выведет код?
class A:
def f(self):
print("A", end="")
class B(A):
def f(self):
print("B", end="")
super().f()
A.f(self)
class C(A):
def f(self):
print("C", end="")
super().f()
A.f(self)
class D(B, C):
def f(self):
print("D", end="")
super().f()
d = D()
d.f()
  • 👨‍💻 1
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 →