+ 1

Help! I need to calculate and output how many players are in the range of one standard deviation from the mean.

players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190] data_sum = sum(players) mean = sum(players) / len(players) new_list = [] for j in players: new_list.append((j - mean) ** 2) var = sum(new_list) / len(new_list) std = var**(1/2) std_pos = mean + std std_neg = mean - std std_list = [] for i in players : if i >= std_neg and i <= std_pos std_list.append(i) print(len(std_list))

13th Oct 2021, 1:09 AM
Caio Picinin
Caio Picinin - avatar
2 Respuestas
+ 3
You're missing a colon `:` at the end of the if statement.
13th Oct 2021, 10:07 AM
Simba
Simba - avatar
0
Is this what you’re looking to do? players = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190] mean = sum(players) / len(players) players_in_range = 0 for j in players: if mean + 1 <= j <= mean - 1: players_in_range += 1 print(players_in_range)
13th Oct 2021, 1:32 AM
Madi
Madi - avatar