01-Nov-2022

.

Admin

Hi Dev,

In this quick example, let's see Python Program Calculate the standard deviation. you can understand a concept of Calculate Standard Deviation in Python. We will look at example of How to Calculate the Standard Deviation of a List in Python. if you have question about standard deviation in python without inbuilt function then I will give simple example with solution. Alright, let’s dive into the steps.

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

so let's see following examples with output:

**Example 1: Python program to calculate standard deviation**

# import statistics library

import statistics

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

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

**Output:**

1.7268882005337975

20.292855885754474

**Example 2: 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

a = [1, 2, 3, 4, 5, 6, 7]

print("Standard Deviation is: ", stdv(a))

b = [1, 2, 3, -4, -5, -6, -7]

print("Standard Deviation is: ", stdv(b))

c = [10, -20, 30, -40, 50, 60, -70]

print("Standard Deviation is: ", stdv(c))

**Output:**

Standard Deviation is: 2.0

Standard Deviation is: 3.843892584878203

Standard Deviation is: 44.62999814803803

I hope it can help you...

#Python

- Laravel 9 Image With Grayscale Example Tutorial
- How To Use Google Map In Vue?
- How To Check File Size When Select Multiple File Validation Using Jquery?
- How to Enable and Disable Debug Mode in Laravel?
- How to Use Has Many Through Relationship in Laravel 10?
- Csrf Token Mismatch on Ajax Request in Laravel 10
- How to Check If String is a Json in PHP?
- JQuery UI Tabs Open On Mouseover Example
- JQuery UI Easing Effects Tutorial | JQuery Easing Effects Animation Example
- How to Get Array of Ids from Eloquent Models in Laravel?