Basketball Players project in Python 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. Here is my code: ------------------------------------ import math players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190] sum = 0 for nums in players: sum+=nums mean = sum / len(players) new_list = [] for i in players: new_list.append(mean-i) new_sum = 0 for k in new_list: new_sum+=k**2 variance = new_sum/len(players) deviation = math.sqrt(variance) #print(variance) #print(deviation) #print(round(variance)) #print(round(deviation)) num_players = [] for j in players: if j in range(round(deviation),round(mean)): num_players.append(j) else: pass print(len(num_players)) ------------------------------------------------- So what I did here is that I found the mean, variance, deviation of the list, I have checked and verified that the mean of this is 112 and the deviation is 11 by rounding them up. I created a new list that contains any numbers from the original list that are in range of 11,112 and I print out the len of that list. I did this in my code playground and I got 4. But the answer is wrong. I am not sure if anything is wrong with my code. Please help me. Thank you