Python Practice › NumPy Programs › Program 31

2 × 3 matrix from 5 to 10

EasyNumPy Programs · 31 of 100

Write a NumPy program to create a 2 × 3 matrix with values from 5 to 10.

Advertisement
Output
[[ 5  6  7]
 [ 8  9 10]]

Approach

  1. np.arange(5, 11).reshape(2, 3).

Solution

Python
import numpy as npprint(np.arange(5, 11).reshape(2, 3))
Output
[[ 5  6  7]
 [ 8  9 10]]
Advertisement

Learn the concept

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

More numpy programs

← All 100 NumPy Programs