Python Tasks & ML | Задачи по питону и машинному обучению
9.4K subscribers
27 photos
1 file
36 links
Algorithms, functions, classes, regular expressions, iterators, generators, OOP, exceptions, NumPy, pandas, scikit-learn
https://telega.in/c/python_tasks

Questions — @dina_ladnyuk
Download Telegram
Что выведет код?
import numpy as np
a = np.arange(4).reshape(2, 2)
b = a[:, np.newaxis, :]
print(b.shape)
Что выведет код?
import numpy as np
x = np.linspace(0, 2, 3)
y = np.linspace(0, 1, 2)
X, Y = np.meshgrid(x, y)
print(int(X.sum()), int(Y.sum()))
Что выведет код?
import numpy as np
x = np.linspace(0, 1, 2)
y = np.linspace(0, 1, 3)
X1, Y1 = np.meshgrid(x, y)
X2, Y2 = np.meshgrid(x, y, sparse=True)
print(*X1.shape, *Y1.shape, *X2.shape, *Y2.shape)
Что выведет код?
import numpy as np
a = np.array([[1, 2], [3, 4]])
b = (a.max(axis=1) - a.min(axis=0)).max()
print(b)
Что выведет код?
import numpy as np
a = np.array([[1, 2], [3, 4]])
x = a.argmin()
y = a.argmax()
print(a.ravel()[x + y])
👍1
Что выведет код?
import numpy as np
a = np.array([[3, 2], [1, -1]])
a.sort()
print(a[-1, 0])
Что выведет код?
import numpy as np
a = np.array([30, 0, -1, 7])
x = np.argsort(a)
print(x[0])
Что выведет код?
import numpy as np
a = np.array([1, 2, 3, 4])
b = np.searchsorted(a, 3.5)
print(b)
Что выведет код?
import numpy as np
a = np.ones(2, dtype='int8,float32,complex')
a[0][0] = 2
a[1][1] = 3
a[0][2] = 4j
print(sum(a[0]).imag + sum(a[1]).real)
Что выведет код?
import numpy as np
dt = np.dtype([('x', 'f8')])
a = np.zeros(4, dtype=dt)
a['x'] = np.array((0., 1., 2., 3.))
print(a['x'][2] + a['x'][3])