Skip to interview prep
Apexed

3. Standardise with NumPy (z-scores)

EasyPandas & NumPy

Given a list of numbers, return their z-scores, (x − mean) / std using the population standard deviation, rounded to 3 decimals. If every value is equal, return zeros.

Example 1

Input: [2, 4, 4, 4, 5, 5, 7, 9]
Output: [-1.5, -0.5, -0.5, -0.5, 0.0, 0.0, 1.0, 2.0]

Constraints

  • 1 ≤ n ≤ 10⁵

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 3 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Standardise with NumPy (z-scores) — coding interview practice — Apexed