Algorithms, functions, classes, regular expressions, iterators, generators, OOP, exceptions, NumPy, pandas, scikit-learn
https://telega.in/c/python_tasks
Questions — @dina_ladnyuk
Post #1009
4.18K
PY @python_tasks
Showing posts older than #1011 · Back to latest
D = {}
A = D
B = D.copy()
B[ 'b' ] = 2
A[ 'b' ] = 3
print(D, B, A)import numpy as np
a = np.array([1, 2, -1])
b = np.diff(a)
print(*b)
import numpy as np
a = np.array([0, 1, -2, 3])
b = a[abs(a) % 2 == 0]
print(*b)
import numpy as np
a, b = np.ones(1), np.ones(1)
a.dtype = 'int'
b = b.astype('int')
print(a[0] == 1, b[0] == 1)
import numpy as np
a, b = np.zeros(1), np.zeros(1)
a.dtype = 'int'
b = b.astype('int')
print(a[0] == 0, b[0] == 0)
import numpy as np
a = np.array([1, 1])
b = np.ndarray([1, 1])
print(*(a.shape + b.shape))
import numpy as np
a = np.array([0.1, 0.25])
b = np.array([0.1, 0.26])
c = np.allclose(a, b, atol=1e-1)
print(c)
import numpy as np
a = np.array([np.nan])
b = np.array([np.nan])
x = np.isclose(a, b)
y = np.isclose(a, b, equal_nan=True)
print(*x, *y)
import numpy as np
a = np.array([0.1, 0.25])
b = np.array([0.3, 0.26])
c = np.isclose(a, b, atol=1e-1)
print(*c)
import numpy as np
a = np.array([1, 1j])
x = np.isreal(a)
y = np.iscomplex(a)
z = x.sum() + y.sum()
print(z)