About Lesson
Numpy functions
Zeros:- this function creates an array (either one dimensional or multi dimensional) and fill all the values with Zero (0).
import numpy as np arr=np.zeros(5) print(arr) |
import numpy as np arr=np.zeros((3,4)) print(arr) |
Ones:- this function creates an array (either one dimensional or multi dimensional) and fill all the values with one (1).
import numpy as np arr=np.ones((3,4)) print(arr) |
Eye:- this function creates an array with all the diagonal elements as 1 and rest as 0.
import numpy as np arr=np.eye(3,4) print(arr) |
import numpy as np arr=np.eye(3) print(arr) |
Diag:- this function creates a two dimensional array with all the diagonal elements as the given value and rest as 0.
import numpy as np arr=np.diag([1,2,3,4]) print(arr) |