- 1

Does anyone know how to solve basketball players 5 code project in python for data science course?

So we are supposed to calculate and output how many players are in the range of one standard deviation from the mean. Below is my code which seems right to me, but when its run the test case says its wrong. Does anyone know how to solve it... players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190] final_inrange = 0 import numpy as np a = np.array([180, 172, 178, 185, 190, 195, 192, 200, 210, 190]) mean = np.sum(a)/a.size print(mean) variance = np.sum((a-mean)**2)/a.size std = np.sqrt([variance]) #print(std) #print(std.format(".2f")) in_range1 = (mean - std) in_range2 = (mean + std) #print(in_range2) for count in range(10): if players[count]>in_range1 and players[count]<in_range2: final_inrange = final_inrange+1 inrange = players[count] #print(inrange) print(final_inrange)

29th May 2022, 10:05 AM
athiyah jasim
2 Respostas
+ 3
players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190] mean = sum(players)/len(players) stdvar = (sum((v-mean)**2 for v in players)/len(players))**0.5 low, high = mean-stdvar,mean+stdvar count = len([v for v in players if low < v < high]) print(count)
29th May 2022, 10:13 AM
Nobody
+ 1
Please do not post in the challenge thread if it isn't a community challenge.
29th May 2022, 10:25 AM
Lisa
Lisa - avatar