All problems
Z-Score
Problem
Return the z-score (x - mean) / std where std is the population standard deviation. Return 0.0 if data is empty or the standard deviation is zero.
Hint
Population variance divides by n.
Test cases
case 1
in: [[1,2,3,4,5],5]
expected: 1.414213562373095
case 2
in: [[1,2,3],2]
expected: 0
case 3
in: [[10],10]
expected: 0
case 4
in: [[2,4,4,4,5,5,7,9],7]
expected: 1
case 5
in: [[],1]
expected: 0
Starter codePython
def zscore(data, x):
# Your code here
pass5 test cases · run your code against them in the editor