Python Practice › NumPy Programs › Program 31
2 × 3 matrix from 5 to 10
Write a NumPy program to create a 2 × 3 matrix with values from 5 to 10.
Output
[[ 5 6 7] [ 8 9 10]]
Approach
np.arange(5, 11).reshape(2, 3).
Solution
import numpy as npprint(np.arange(5, 11).reshape(2, 3))Output
[[ 5 6 7] [ 8 9 10]]
Learn the concept
New to this topic? Read the lesson, then come back.