import statistics
a = [1,2,3,4,5]
mean = statistics.mean(a)
#Similar for other values such as variance, standard deviation
numbers = [3, 18, 2, 1, 70, 12, 36, 12, 78, 5, 6, 9]
import statistics
print(statistics.mean(numbers))
def calculate_mean(n):
s = sum(n)
N = len(n)
mean = s / N
return mean
# --------------------- MEAN ---------------------
# Dataset for questions -
dataset = [2, 1, 1, 4, 5, 8, 12, 4, 3, 8, 21, 1, 18, 5]
# Finding sum of dataset
sumOfDataset = sum(dataset)
# Finding length of dataset
lenOfDataset = len(dataset)
# Calculating the mean by dividing the sum of dataset with the length of dataset
mean = sumOfDataset / lenOfDataset
# Printing the mean of dataset
print(mean)
def mean(numbers):
numbers.sort()
q = len(numbers) // 2
if len(numbers) % 2 !=0:
return numbers[q]
elif len(V) % 2 == 0:
return (numbers[q - 1] + numbers[q]) / 2