# Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
import math
import statistics
data = [10, 4, 7, 9, 4, 6, 8, 1, 9, 8]
def standDev(a, b, c, d, e, f, g, h, i, j):
n = [a, b, c, d, e, f, g, h, i, j]
len_ = len(n)
mean =sum(n)/len_
less_mean = 0
total = sum((x - mean) ** 2 for x in n) / ( len_ - less_mean)
return math.sqrt(total)
def standDev2(a, b, c, d, e, f, g, h, i, j):
n = [a, b, c, d, e, f, g, h, i, j]
len_ = len(n)
mean =sum(n)/len_
less_mean = 0
total = 0
for x in n:
total += (x - mean) ** 2
return math.sqrt( total / ( len_ - less_mean) )
print(standDev(*data))
print(standDev2(*data))
print(statistics.stdev(data))
print(statistics.pstdev(data))
You can check the output or the code by pasting the above code into the online python interpreter.
Output:
2.6907248094147422
2.6907248094147422
2.836272984824353
2.6907248094147422