# Python Program Calculate the standard deviation

Python program find standard deviation; In this tutorial, you will learn how to find standard deviation in python with and without inbuilt function.

## Python Program Calculate the standard deviation

• Python program to calculate standard deviation
• How to find standard deviation in python without inbuilt function

### Python program to calculate standard deviation

```# import statistics library
import statistics

print(statistics.stdev([1,2,3,4,5,5,5,6,7,8]))

print(statistics.stdev([40,45,35,10,15,18,12,16], 45))
```

Output

```2.1705094128132942
13.829962297231946```

Note:- `stdev()` function in python is the Standard statistics Library of Python Programming Language. The use of this function is to calculate the standard deviation of given continuous numeric data.

### How to find standard deviation in python without inbuilt function

```#define a function, to calculate standard deviation
def stdv(X):
mean = sum(X)/len(X)
tot = 0.0
for x in X:
tot = tot + (x - mean)**2
return (tot/len(X))**0.5

# call function with following data set
x = [1, 2, 3, 4, 5, 6, 7, 8]
print("Standard Deviation is: ", stdv(x))

y = [1, 2, 3, -4, -5, -6, -7, -8]
print("Standard Deviation is: ", stdv(y))

z = [10, -20, 30, -40, 50, 60, -70, 80]
print("Standard Deviation is: ", stdv(z))

```

Output

```Standard Deviation is:  2.29128784747792
Standard Deviation is:  4.06201920231798
Standard Deviation is:  48.925964476952316```

## Recommended Python Programs 