In this python numpy program, we will create a 2×3 matrix filled with values from 5-10 using NumPy.
Steps to solve the program
- Import the numpy library as np.
- Create an array filled with values from 5-10 using np.arange().
- Now convert the array to create a 2×3 matrix using reshape.
- Print the output.
import numpy as np
x = np.arange(5,11)
x.reshape(2,3)
Output :
array([[ 5, 6, 7],
[ 8, 9, 10]])