Python Practice › NumPy Programs › Program 27
2 × 3 matrix
Write a NumPy program to create a 2 × 3 matrix.
Output
[[1 2 3] [4 5 6]]
Approach
- Reshape 6 numbers.
Solution
import numpy as npprint(np.arange(1, 7).reshape(2, 3))Output
[[1 2 3] [4 5 6]]
Learn the concept
New to this topic? Read the lesson, then come back.