PIXELBANKv9.1.0
Menu

Problem Statement

Examine and report properties of a NumPy array.

Background

NumPy arrays have useful properties:

  • shape: Tuple of dimensions
  • dtype: Data type
  • size: Total number of elements
  • ndim: Number of dimensions

Your Task

Write a function array_info(arr) that returns information about an array.

Output Format

Return a dictionary with:

  • "shape": Tuple of dimensions (as list)
  • "dtype": Data type as string
  • "size": Total elements
  • "ndim": Number of dimensions
  • "is_matrix": True if 2D, False otherwise

Example:

Input:
np.array([[1, 2, 3], [4, 5, 6]])
Output:
{'shape': [2, 3], 'dtype': 'int64', 'size': 6, 'ndim': 2, 'is_matrix': True}
Reasoning:

2 rows × 3 cols = 6 elements, 2D array is a matrix

Constraints:

  • dtype output may vary by system (int64, int32, float64, etc.)
  • Accept both int64 and int32 as valid integer dtypes
solution.py

Test Results

0/0
Run code to see test results.
Array Properties - Easy | PixelBank