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

Older Posts 20 shown
Post #2320 1.3K
Что выведет код?
class MyExc(Exception):
def __str__(self):
return 'my-exc'
try:
raise MyExc()
print('try')
except MyExc as err:
print(err)
else:
print('else')
  • 👍 3
Post #2318 1.2K
Что выведет код?
val = # ваш код
shoes = {'name': 'fashion shoes', 'price': 14900}
def discount(item, discount):
price = int(item['price']) * (1.0 - discount)
assert 0 <= price <= item['price']
return price
discount(shoes, val)
  • 👎 9
Post #2316 1.05K
Что выведет код?
sum([3 >> i for i in range(200)])
Post #2314 1.18K
Что выведет код?
class Error(Exception): pass

def handle(file):
raise Error()

file = open('mydata', 'w')

try:
handle(file)
print('one')
finally:
file.close()

print('two')
Post #2312 1.09K
Что выведет код?
class A:
def message(self):
print('1', end='')

def __enter__(self):
print('2', end='')
return self

def __exit__(self, exc_type, exc_value, exc_tb):
if exc_type is None:
print('3', end='')
else:
print ('4', end='')
return True

with A() as action:
action.message()
Post #2310 1.26K
Что выведет код?
def f(*seqs):
seqs = [list(s) for s in seqs]
while all(seqs):
yield tuple(s.pop(0) for s in seqs)
s1, s2 = 'ab', '123'
print(list(f(s1, s2)))
Post #2308 1.17K
Что выведет код?
x = 0
try:
x += 1
try:
x += 1
1/0
except ZeroDivisionError:
x += 1
except ZeroDivisionError:
x += 1
else:
x += 1
print(x)
Post #2306 1.11K
Что выведет код?
sum([1 << i for i in range(5)])
Post #2304 1.24K
Что выведет код?
d = {'a': 1, 'b': 2, 'c': 3}
x = [string for string, digit in d.items() if digit > 1]
print(x)
Post #2302 1.16K
Что выведет код?
x = 0
try:
x += 1
except ZeroDivisionError:
x += 1
else:
x += 1
1/0
x += 1
print(x)
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 →