**statistics.pstdev() Method in Python:**

The statistics.pstdev() method computes the standard deviation from a population as a whole.

The standard deviation measures how evenly distributed the numbers are.

A high standard deviation indicates that the data is dispersed, whereas a low standard deviation indicates that the data is tightly clustered around the mean.

Tip: Unlike variance, the standard deviation is expressed in the same units as the data.

Tip: The standard deviation is equal to the square root of the sample variance.

Look at the statistics.stdev() method to calculate the standard deviation from a sample of data.

**Syntax:**

statistics.pstdev(data, xbar)

**Parameters**

**data:** This is Required. It is the data values that will be used (it can be any sequence, list, or iterator).

**xbar:** This is Optional. The arithmetic mean of the given data (can also be a second moment around a point that is not the mean). If omitted (or set to None), the mean is calculated automatically.

**Note:** It is important to note that if the data is empty, it returns a StatisticsError.

**Return Value:**

Returns aÂ float value representing the given data’s population standard deviation.

**Examples:**

**Example1:**

**Input:**

Given list = [10, 20, 40, 15, 30]

**Output:**

The standard deviation of the given list items [10, 20, 40, 15, 30] = 10.770329614269007

**Example2:**

**Input:**

Given list = [3, 4, 5, 1, 3, 2]

**Output:**

The standard deviation of the given list items [3, 4, 5, 1, 3, 2] = 1.2909944487358056

statistics.pstdev() Method with Examples in Python

### Method #1: Using Built-in Functions (Static Input)

**Approach:**

- Import statistics module using the import keyword.
- Give the list as static input and store it in a variable.
- Pass the given list as an argument to the statistics.pstdev() method that computes the standard deviation from a population as a whole.
- Store it in another variable.
- Print the standard deviation of the given list items.
- The Exit of the Program.

**Below is the implementation:**

# Import statistics module using the import keyword. import statistics # Give the list as static input and store it in a variable. gvn_lst = [10, 20, 40, 15, 30] # Pass the given list as an argument to the statistics.pstdev() method that # computes the standard deviation from a population as a whole. # Store it in another variable. rslt = statistics.pstdev(gvn_lst) # Print the standard deviation of the given list items. print("The standard deviation of the given list items", gvn_lst, "= ", rslt)

**Output:**

The standard deviation of the given list items [10, 20, 40, 15, 30] = 10.770329614269007

### Method #2: Using Built-in Functions (User Input)

**Approach:**

- Import statistics module using the import keyword.
- Give the list as user input using list(),map(),input(),and split() functions.
- Store it in another variable.
- Pass the given list as an argument to the statistics.pstdev() method that computes the standard deviation from a population as a whole.
- Store it in another variable.
- Print the standard deviation of the given list items.
- The Exit of the Program.

**Below is the implementation:**

# Import statistics module using the import keyword. import statistics # Give the list as user input using list(),map(),input(),and split() functions. # Store it in a variable. gvn_lst = list(map(int, input( 'Enter some random List Elements separated by spaces = ').split())) # Pass the given list as an argument to the statistics.pstdev() method that # computes the standard deviation from a population as a whole. # Store it in another variable. rslt = statistics.pstdev(gvn_lst) # Print the standard deviation of the given list items. print("The standard deviation of the given list items", gvn_lst, "= ", rslt)

**Output:**

Enter some random List Elements separated by spaces = 3 4 5 1 3 2 The standard deviation of the given list items [3, 4, 5, 1, 3, 2] = 1.2909944487358056