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 is the result of calculating this function called??
def f(n):
return n * f(n-1) if n > 1 else 1
What will this code do?
def f(arr):
return 0 if not arr else arr[0] + f(arr[1:])
print(f([]))
What will this code do?
def f(arr):
return arr[0] if len(arr) == 1 else arr[0] + f(arr[1:])
print(f([]))
What will this code do?
def f(arr):
first, *rest = arr
return first if not rest else first + f(rest)
print(f([]))
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')))