Algorithms, functions, classes, regular expressions, iterators, generators, OOP, exceptions, NumPy, pandas, scikit-learn
https://telega.in/c/python_tasks
Questions — @dina_ladnyuk
Post #2361
1.27K
- 👏 3
PY @python_tasks
Showing posts older than #2362 · Back to latest
~(10 ^ ~10) + ~~(100 ^ ~100) + ~~~(1000 ^ ~1000)
chr(ord('c') - ord('a') + ord('b'))try:
try:
raise IndexError()
except Exception as E:
raise TypeError() from E
except Exception as E:
raise SyntaxError() from E
class Odd(Exception): pass
def check_even(x):
if x % 2:
raise Odd()
else:
return True
try:
result = check_even(6)
print(result, end=' ')
except Odd:
print('Нечетный')
else:
print('Четный')
x = 1
try:
1/0
except Exception as x:
print(x)
print(x)
def f1():
raise IndexError
def f2():
return
def f3():
raise SyntaxError
counters = []
for func in (f1, f2, f3):
counter = 0
try:
try:
func()
except IndexError:
counter += 1
except SyntaxError:
counter += 1
finally:
counter += 1
counters.append(counter)
print(counters)
def g(*args):
return sum([f() if callable(f) else f for f in args])
x = g(lambda: 1, lambda: 2, 3, 4)
print(x)
256 >> 7 << 1 << 2 >> 3 >> 1