

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python – Mean deviation of Elements
When it is required to find the mean deviation of the elements of a list, the ‘sum’ method and the ‘len’ method is used.
Example
Below is a demonstration of the same
my_list = [3, 5, 7, 10, 12] print("The list is :") print(my_list) my_mean = sum(my_list) / len(my_list) my_variance = sum([((x – my_mean) ** 2) for x in my_list]) / len(my_list) my_result = my_variance ** 0.5 print("The result is :") print(result)
Output
The original list : [3, 5, 7, 10, 12] the standard deviation of list is : 3.2619012860600183
Explanation
A list is defined and is displayed on the console.
The ‘sum’ of the list and the ‘len’ of the list is obtained.
The ‘sum’ is divided by the ‘len’.
This is assigned to a variable.
Now, the elements in the list are iterated and squared.
Their sum is obtained and assigned to another variable.
The square root of the above variable is obtained and assigned to a ‘result’.
This is the output that is displayed on the console.
- Related Questions & Answers
- Absolute Deviation and Absolute Mean Deviation using NumPy
- PyTorch – How to normalize an image with mean and standard deviation?
- Python – Get Matrix Mean
- Program for Mean Absolute Deviation in C++
- Plot mean and standard deviation in Matplotlib
- Find Rolling Mean – Python Pandas
- C++ code to find minimum arithmetic mean deviation
- Python – Remove Columns of Duplicate Elements
- Python – Summation of consecutive elements power
- How to compute the mean and standard deviation of a tensor in PyTorch?
- Write a Python program to find the mean absolute deviation of rows and columns in a dataframe
- Python – K middle elements
- Python – Fractional Frequency of elements in List
- Python – Random insertion of elements K times
- Python – Grouped Consecutive Range Indices of Elements
Advertisements