PIXELBANKv9.1.0
Menu

Create Arrays with Special Values

Problem Statement

Create NumPy arrays filled with special values (zeros, ones, specific values).

Background

NumPy provides functions to create pre-filled arrays:

  • np.zeros(shape): Array of zeros
  • np.ones(shape): Array of ones
  • np.full(shape, value): Array filled with specific value
  • np.empty(shape): Uninitialized array

Your Task

Write a function create_special_arrays(rows, cols) that returns a dictionary with:

  • "zeros": Array of zeros as nested list
  • "ones": Array of ones as nested list
  • "fives": Array filled with 5s as nested list

Output Format

Return a dictionary with exactly these three keys.

Example:

Input:
rows = 2, cols = 3
Output:
{'zeros': [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], 'ones': [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0]], 'fives': [[5, 5, 5], [5, 5, 5]]}
Reasoning:

Creates 2x3 arrays with different fill values

Constraints:

  • Use np.zeros(), np.ones(), np.full()
  • rows and cols will be positive integers
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Create Arrays with Special Values - Easy | PixelBank