The purpose of this question is writing a code that can calculate the standard deviation of a list of numbers that user
Posted: Sun Jul 03, 2022 12:01 pm
question is writing a code that can calculate the standard deviation of a list of numbers that user enters. For this purpose, you may use (or rewrite) the grabList() function that you wrote for Question 1. Then you need another function that can calculate the average of the entered elements. The input of that function would be the list that the user entered in the first step. def avg_calc(Is): The function avg_cale should be called inside another function where the standard deviation is calculated. This function is: def sd_calc(ave_calls): In sd_calc, the differences between each entered data in the primary list and the mean that is calculated in the avg_calc are powered by two and added together. After adding the power two of all the difference between each list element and the average of the list, then calculate the square root of the result to find the standard deviation of the list elements. The example below shows how the standard deviation is calculated: 1) We have list of numbers (this part is done in the grabList function): 2, 4, 4, 4, 5, 5, 7, 9 2) Calculate the mean of the list (this part is done in ave_calc function): 2+4+4+4+5+5+7+9 8 3) Find the difference between each element and the average: (this part is done in the sd_calc function): (2-5)² = (-3)² = 9 (4-5)² = (-1)² = 1 (4-5)² = (-1)² = 1 (4-5)² = (-1)² = 1 (5-5)² = 0²-0 (5-5)²=0²=0 (7-5)² =2²=4 (9-5)² =4²=16 4) Add the difference that you calculated in item 3 (this part is done in the sd_calc function): 9+1+1+1+0+0+4+16 8 5) Find the square root of the result of item 4 and print it (this part is done in the sd_calc function): o = √4=2 Test your program using different lists with different lengths and elements. Note: Make sure that your code is working for any input and not only the examples that arealready explained in the question.
Enter the length of the list: 5 Enter element 1:4 Enter element 2:2 Enter element 3:5 Enter element 4:8 Enter element 5:6 Sample data: [4, 2, 5, 8, 6] Standard Deviation: 2.0 Programmed by Stew Dent. Date: Fri Jun 17 10:42:56 2022 End of processing.
The purpose of this Enter the length of the list: 5 Enter element 1:4 Enter element 2:2 Enter element 3:5 Enter element 4:8 Enter element 5:6 Sample data: [4, 2, 5, 8, 6] Standard Deviation: 2.0 Programmed by Stew Dent. Date: Fri Jun 17 10:42:56 2022 End of processing.