0
Basketball player challenge of python data science .I wrote following code but it doesn't work . what's wrong?
players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190] mean = sum (players)/len(players) list1 =[] for i in players : data = (i - mean )**2 list1.append (data) sum =0 for i in list1 : sum += i sum =(sum**(1/2)) list2=[] for i in players : if (mean-sum)<= i <= (mean+sum): list2.append (i) print (len(list2))
2 Antworten
+ 1
#Try_this_hope_this_will_help_you
import math
players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190]
b=sum(players)
c=b/len(players)
d=[]
for i in range(len(players)):
e=int(c)-players[i]
d.append(e**2)
f=sum(d)
g=f/len(d)
h=(math.sqrt(g))
i=c-h
j=c+h
k=[]
for l in players:
if (l>i) and (l<j):
k.append(l)
print(len(k))
0
What is the question?