Python & ML tasks
416 subscribers
2 photos
3 links
Python, functions, classes, iterators, generators, numpy, pandas, scikit-learn, TensorFlow
for advertising: @dina_ladnyuk

For advertising and donations in USD:
SWIFTBIC BUKBGB22
IBAN GB40 BUKB 2047 3453 2396 99
Mrs Dina Ladnyuk
Download Telegram
What will this code do?
def f(n):
def g(x):
return x**n
return g
g = f(2)
print(g(7))
What will this code do?
def f():
_x = None
def g(x=None):
nonlocal _x
if x is None:
return _x
_x = x
return g
g = f()
print(g(), g(10), g(), g(5), g())
What will this code do?
def f(x):
y = x ** 2
return y
print(*f.__code__.co_varnames)
Choose the correct answer
Anonymous Quiz
0%
x
9%
x 2
45%
x y
18%
x y 2
0%
y 2
18%
y
9%
See solution
What will this code do?
def f(x, y):
f.y = y
f.z = f.y
return x
print(f(1, 2), [x for x in dir(f) if not x.startswith('__')])
What will this code do?
def f(arr):
return 0 if not arr else arr[0] + f(arr[1:])
print(f(('a', 'b', 'c', 'd')))
What will this code do?
def f(arr):
return arr[0] if len(arr) == 1 else arr[0] + f(arr[1:])
print(f(('a', 'b', 'c', 'd')))
What will this code do?
def f(arr):
first, *rest = arr
return first if not rest else first + f(rest)
print(f(('H', 'e', 'l', 'l', 'o')))
What will this code do?
def f(a: int, b: float) -> int:
return a * int(b)
print(f(5, 2.1))
Choose the correct answer
Anonymous Quiz
0%
7.1
87%
10
7%
10.5
7%
TypeError
0%
SyntaxError
What will this code do?
def func(a: str, b: int):
return a + b
func(1, 2)
for arg in sorted(func.__annotations__):
print(arg, func.__annotations__[arg])
break
What will this code do?
def f(x, y):
z = x ** y
return z
print(f.__code__.co_argcount)