Skip to content
C

Problem 3: Reshape a 1D Array into a 2D Grid

Easypython

Problem Description

Write a Python program that creates a 1D NumPy array of numbers from 1 to 12 using np.arange(), then reshapes it into a 3x4 2D array and prints both the original and reshaped arrays.

Input

None (values are generated within the program).

Output

The original 1D array, followed by the reshaped 3x4 array.

Constraints

  • The total number of elements must exactly match the target shape (12 = 3 × 4).

Example Input

text
(no input required)

Example Output

text
Original: [ 1 2 3 4 5 6 7 8 9 10 11 12] Reshaped: [[ 1 2 3 4] [ 5 6 7 8] [ 9 10 11 12]]

Concepts Covered

np.arange(), reshape(), array shape.

Input (stdin)

Output

Run your code to see output here...