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(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)
What will this code do?
def f(arr):
s = 0
for x in arr:
if not isinstance(x, list):
s += x
else:
s += f(x)
return s
print(f([1, [2, [3, [4, [5]]]]]))
👍1
What will this code do?
from collections.abc import Iterable
def f(arr):
s = 0
items = list(arr)
while items:
first = items.pop(0)
if not isinstance(first, Iterable):
s += first
else:
items.extend(first)
return s
print(f((1, (2, (3, (4, (5)))))))
Choose the correct answer
Anonymous Quiz
17%
0
17%
1
42%
15
17%
12345
8%
None
0%
TypeError
What will this code do?
def f(L):
s = ''
items = list(L)
while items:
first = items.pop(0)
if isinstance(first, str):
s += first
else:
items[:0] = first
return s
print(f(('a', ('b', ('c', ('d', 'e'))))))
What will this code do?
def f(a: int = 2, b: int = 2) -> int:
return a ** b
print(f(3))
What will this code do?
def f(a: int = 2, b: int = 2) -> int:
return a ** b
print(f(3))
Which expression would be equivalent for a ternary operator
"B if a else с", considering that the variables b and c contains some objects, and the variable a - a boolean value.
Anonymous Quiz
0%
a or b and c
10%
a and b and c
20%
a or b or c
25%
a or c and b
25%
a and b or с
5%
a and c or b
15%
See solution
What will this code do?
f = (lambda x, y: x if х < y else y)
z1 = f('b', 'а')
z2 = f('а', 'b')
print(z1 == z2)