Numpy

Mon 21 July 2025
# Cell 1
import numpy as np
# Cell 2
a = np.array([1, 2, 3])
# Cell 3
b = np.array([[1, 2], [3, 4]])
# Cell 4
np.zeros((2, 3))
# Cell 5
np.ones((3, 3))
# Cell 6
np.eye(4)  # Identity matrix
# Cell 7
np.arange(10, 50, 5)
# Cell 8
np.linspace(0, 1, 5)
# Cell 9
np.full((2, 2), 7)
# Cell 10
np.random.rand(3, 3)
# Cell 11
arr = np.arange(10)
arr
# Cell 12
arr[3:7]
# Cell 13
arr[::-1]
# Cell 14
arr[::2]
# Cell 15
b = np.array([[1, 2, 3], [4, 5, 6]])
b[:, 1]







Score: 20

Category: basics