import numpy numpy.linalg.norm import numpy as np np.lookfor("solve") np.e np.pi np.log(2) np.array([1, 2, 3]) a = np.array([1, 2, 3.0]) print(a.dtype) np.array([1, 2, "3"]) np.array([1, 2, 3], dtype=float) np.array([1, 2, 3], dtype=complex) a a.astype(int) N, M = 100, 100 a = np.empty(10000).reshape(N, M) b = np.random.rand(10000).reshape(N, M) c = np.random.rand(10000).reshape(N, M) %%timeit for i in range(N): for j in range(M): a[i, j] = b[i, j] + c[i, j] %%timeit a = b + c a = np.array([ [1, 2, 3], [4, 5, 6] ]) a a[0] a[0, 0] a[0, 1:3] a[0, ::2] np.identity(5).astype(int) _.shape np.zeros((3, 4)) np.zeros(3, 4) np.ones((3, 4)) i3 = np.identity(3) i3 i3.shape np.ones(i3.shape) np.ones_like(i3) np.linspace(0, 1, num=10) np.logspace(0, 3) x = np.linspace(0, 1, num=5) y = np.linspace(0, 1, num=5) xx, yy = np.meshgrid(x, y) xx, yy xx + 1j * yy a = np.arange(2 * 3).reshape(2, 3) a np.sqrt(a) np.sqrt(np.arange(-3, 3)) np.arange(-3, 3).astype(complex) np.sqrt(_) a = np.arange(6) b = np.ones(6).astype(int) a, b a < b np.any(a < b) np.all(a < b) a = np.arange(6).astype(float) b = np.ones(6) a, b np.isclose(a, b, rtol=1e-6) np.allclose(a, b, rtol=1e-6) 0.1 + 0.2 + 0.3 0.3 + 0.2 + 0.1 0.1 + 0.2 + 0.3 == 0.3 + 0.2 + 0.1 a = np.zeros((3, 4)) a a[0, :] = 1 a b = np.zeros((3, 4)) b[-1] = np.arange(5, 9) b v = np.ones(10) v v[::2] = 2 v tablero = np.zeros((8, 8)) tablero tablero[1::2, ::2] = 1 tablero[::2, 1::2] = 1 tablero