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

Older Posts 20 shown
Post #2721 787
Что выведет код?
s = [1, 2, 1]
print(s.index(1), s.index(2))
Post #2719 744
Что выведет код?
s = [1, 2, 3]
s.append(3)
s = list(sorted(set(s)))
s.pop()
s.remove(1)
print(*s)
Post #2717 772
Что выведет код?
s = [1, 2, 3, 4]
s.insert(2, 100)
del s[:2]
s.pop()
s.remove(3)
print(*s)
Post #2715 877
Что выведет код?
def f():
yield 0
yield from [1, 2]
yield 3
print(*f())
Post #2713 864
Что выведет код?
values = [8, 3, 1]
group = {2, 7}
def f(values, group):
count = 0
def g(x):
nonlocal count
if x in group:
count += 1
return (0, x)
return(1, x)
values.sort(key=g)
return count
count = f(values, group)
print(count)
Post #2711 754
Что выведет код?
def f(x):
if x in group:
return (0, x)
return (1, x)
group = {5, 6, 7}
values = {4, 9, 7, 8, 3, 5}
print(*sorted(values, key=f))
Post #2709 711
Что выведет код?
a, b = 1, 0
def divide1(a, b):
try:
return a / b
except ZeroDivisionError:
return None
def divide2(a, b):
try:
return True, a / b
except ZeroDivisionError:
return False, None

print(divide1(a, b), *divide2(a, b))
Post #2707 728
Что выведет код?
s = 0
try:
s += 1/0
except ZeroDivisionError:
s += 1
else:
s += 5
finally:
s += 10
print(s)
Post #2705 821
Что выведет код?
from itertools import zip_longest
x = [1, 2, 3]
y = ["a", "b"]
l = list(zip(x, y))
m = list(zip_longest(x, y))
print(l == m)
Post #2703 771
Что выведет код?
sum(x[0] for x in enumerate(range(2), 5))
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 →