X = [56, 31, 56, 8, 32] # 1. enter the data
X_bar = mean(X) # 2. find the mean of the data
AD = [] # 3. find the absolute value of the difference between
for i in X: # each value and the mean and add it to the list AD
AD.append(abs((i-X_bar)))
AAD = mean(AD) # 4. find the mean of the absolute values
print(AAD)
Correcting variable naming in python code:
from statistics import mean
X = [56, 31, 56, 8, 32] # 1. enter the data X_bar = mean(X) # 2. find the mean of the data AD = [] # 3. find the absolute value of the difference between for i in X: # each value and the mean and add it to the list AD
AD.append(abs((i-X_bar)))
AAD = mean(AD) # 4. find the mean of the absolute values print(AAD)