Python Practice › NumPy Programs › Program 28
2 × 2 matrix
Write a NumPy program to create a 2 × 2 matrix.
Output
[[1 2] [3 4]]
Approach
- From a nested list.
Solution
import numpy as npprint(np.array([[1, 2], [3, 4]]))Output
[[1 2] [3 4]]
Learn the concept
New to this topic? Read the lesson, then come back.