PIXELBANKv9.1.0
Menu

Problem Statement

Calculate basic statistics of a NumPy array.

Background

NumPy provides statistical functions:

  • np.sum(): Sum of elements
  • np.mean(): Average
  • np.min(), np.max(): Min and max
  • np.std(): Standard deviation

Your Task

Write a function array_stats(arr) that returns a dictionary with:

  • "sum": Sum of all elements
  • "mean": Mean (average), rounded to 2 decimals
  • "min": Minimum value
  • "max": Maximum value
  • "std": Standard deviation, rounded to 2 decimals

Output Format

Return a dictionary with exactly these five keys.

Example:

Input:
[1, 2, 3, 4, 5]
Output:
{'sum': 15, 'mean': 3.0, 'min': 1, 'max': 5, 'std': 1.41}
Reasoning:

sum=15, mean=3, min=1, max=5, std≈1.41

Constraints:

  • Round mean and std to 2 decimal places
  • Array will have at least 1 element
🔒

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.