Step 1: Installing NumPy
pip install numpy
Step 2: Importing NumPy
import numpy as np
Step 3: NumPy Arrays
1D Array
arr_1d = np.array([1, 2, 3])
2D Array
arr_2d = np.array([[1, 2, 3], [4, 5, 6]])
3D Array
arr_3d = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])
Step 4: Array Operations
Element-wise Addition
result = arr_1d + arr_1d
Element-wise Multiplication
result = arr_2d * arr_2d
Dot Product of Matrices
result = np.dot(arr_2d, arr_2d.T)
Step 5: Saving and Loading Data
Saving Data
np.save('my_array', arr_1d)
Loading Data
loaded_array = np.load('my_array.npy')