+ 2
Tell me mistakes. Calculate the range of one standard deviation.
players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190] mean = sum(players)/len(players) sqr = 0 for i in players: sqr += (i-mean)**2 std = sqr/len(list)**0.5 x = 0 for i in players: if i > mean-std and i < mean-std: x += 1 print(x)
10 odpowiedzi
0
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)
+ 3
It's the first end of module project of the Python for Data Science course:
"The given code includes a list of heights for various basketball players.
You need to calculate and output how many players are in the range of one standard deviation from the mean."
+ 2
You should put your code in the playground and save it. Then paste a link here so we can see it as you update it
+ 1
Jayakrishna🇮🇳 Slick
I suppose it is a task from the data science course
+ 1
Bobby for the future:
1. Always include the task description. It's hard to help you when you don't tell people what you're trying to do.
2. Post your code in the code playground and link it here. It's far easier to figure out what is going on when you can run the code and "play around" with it.
0
'list' is a type and therefore has no length.
'i' cannot be less than AND greater than another value
Bobby i didn't know that i told you impropely. I'm not really sure what the program does, but those lines will cause issues with your expected output.
0
Can u tell me properly?
0
additionally:
std is (sqr/len(...))**0.5
(You forgot the outer brackets)
0
It's not passing the test
0
@Bobby You are using len(list) but you may need len(players) for std calculations... ..
And if condition in last loop never comes true.
What you need to calculate actually?