Python Practice › NumPy Programs › Program 27

2 × 3 matrix

EasyNumPy Programs · 27 of 100

Write a NumPy program to create a 2 × 3 matrix.

Advertisement
Output
[[1 2 3]
 [4 5 6]]

Approach

  1. Reshape 6 numbers.

Solution

Python
import numpy as npprint(np.arange(1, 7).reshape(2, 3))
Output
[[1 2 3]
 [4 5 6]]
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More numpy programs

← All 100 NumPy Programs