Code coach basketball player
Can someone please explain this question And what's wrong in this solution import numpy as n players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190] arr=n.array(players) x=arr[arr>arr.std()] x=x[x<arr.mean()] print(x.size)
4/7/2021 5:42:40 AM😴 Wake Up 💤
5 AnswersNew Answer
See according to the question You need to calculate how many players are in the range of one standard deviation from the mean. And the range of one standard deviation from the mean means the range from ((Mean - standard deviation ) , (Mean+ standard deviation)). See I did some changes in ur code . Now I just used that range formula there: https://code.sololearn.com/c4NREZQX7I8A/?ref=app
✨Kårï§hmå✨ thanks sista Can you please explain this question?
✨Kårï§hmå✨ thank you very much sista
Although flipping the sign ends up resulting in the same number of elements in the final array, they aren't the correct elements and the suggested answer is incorrect. This line; x=arr[arr>arr.std()] Just ends up copying the original array to the variable x, since all values in the original array are greater than the standard deviation of the array. The next line, when corrected as suggested; x=x[x>arr.mean()] creates a new array of all the values in x that are greater than the mean value of all the elements in x, and saves them back into the x variable. There just happens to be 6 values (x.size) that meet this condition. What is intended is for you to find all the values that are within the mean ± the standard deviation. So, if the mean were 180 and the standard deviation were 10 you would get all the numbers in the array from 170-190 and output the count. Edit: didn't see ✨Kårï§hmå✨ second answer which is correct. Except, the use of the range() function, which could error as it only works with integers.
ChaoticDawg thanks for better explanation