Skip to content
CampusEduX

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

Easypython
Learn the Concept: NumPy

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.

Related Problems

  • Problem 1: Array Statistics Calculator
    Easy · python
    Solve Problem
  • Problem 2: Add Bonus Marks Using Vectorization
    Easy · python
    Solve Problem
  • Problem 4: Compare Two Arrays Element-Wise
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...