Standard deviation of list - Python Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report We are given a list of numbers, and our task is to compute the standard deviation. Standard deviation is a measure of how spread out the numbers are from the mean. A low standard deviation means the values are close to the mean, while a high standard deviation indicates the values are spread out. For example, given the list [10, 12, 23, 23, 16, 23, 21, 16], we need to calculate its standard deviation.Using statistics.stdev()We can use the stdev() function from Python's statistics module to calculate the standard deviation of a list. This method works well for small datasets. Python import statistics # List of numbers a = [10, 12, 23, 23, 16, 23, 21, 16] # Calculate standard deviation b = statistics.stdev(a) print(b) Output5.237229365663818 Explanation: statistics.stdev(a) computes the sample standard deviation. This method works well for small datasets.Using numpy.std()If we are working with large lists, the numpy library provides the std() function, which calculates the population standard deviation by default, but we can adjust it for sample standard deviation by setting ddof=1. Python import numpy as np # List of numbers a = [10, 12, 23, 23, 16, 23, 21, 16] # Calculate standard deviation b = np.std(a, ddof=1) print(b) Output5.237229365663817 Explanation:np.std(a, ddof=1) computes the sample standard deviation.It is optimized for numerical operations on large datasets.Using pandas.Series.std()For data analysis tasks, the pandas library is often used, which provides a convenient std() method to compute the standard deviation of a list or column in a DataFrame. Python import pandas as pd a = [10, 12, 23, 23, 16, 23, 21, 16] # Convert list to pandas Series series = pd.Series(a) # Calculate standard deviation b = series.std() print(b) Output5.237229365663817 Explanation:We convert the list to a pandas.Series.The .std() method is used to compute the sample standard deviation. Comment More infoAdvertise with us Next Article Find the size of a list - Python M manjeet_04 Follow Improve Article Tags : Python Python Programs Python list-programs Practice Tags : python Similar Reads Create a List of Strings in Python Creating a list of strings in Python is easy and helps in managing collections of text. For example, if we have names of people in a group, we can store them in a list. We can create a list of strings by using Square Brackets [] . We just need to type the strings inside the brackets and separate the 3 min read List of strings in Python A list of strings in Python stores multiple strings together. In this article, weâll explore how to create, modify and work with lists of strings using simple examples.Creating a List of StringsWe can use square brackets [] and separate each string with a comma to create a list of strings.Pythona = 2 min read Find the size of a list - Python In Python, a list is a collection data type that can store elements in an ordered manner and can also have duplicate elements. The size of a list means the amount of memory (in bytes) occupied by a list object. In this article, we will learn various ways to get the size of a python list. 1.Using get 2 min read Find the size of a list - Python In Python, a list is a collection data type that can store elements in an ordered manner and can also have duplicate elements. The size of a list means the amount of memory (in bytes) occupied by a list object. In this article, we will learn various ways to get the size of a python list. 1.Using get 2 min read Python - Create List of Size n Creating a list of size n in Python can be done in several ways. The easiest and most efficient way to create a list of size n is by multiplying a list. This method works well if we want to fill the list with a default value, like 0 or None.Python# Size of the list n = 5 # Creating a list of size n 2 min read Python List Creation Programs Python provides multiple ways to create lists based on different requirements, such as generating lists of numbers, creating nested lists, forming lists of tuples or dictionaries, and more.This article covers various ways to create lists efficiently, including:Generating lists of numbers, strings, a 2 min read Like