Use spyder
Please take a screenshot and make sure the codes are working. Thank you
Each program must start with a multi-line comment as shown below. For Assignment 2 question 2,you should replace x with 2 and y with 2. Replace each occurrence of DentStew and StewDent with your name. Replace yyyy/mm/dd with the date you completed the program. # DentStewAxQy.py # # Course: # Instructor: # Assignment: # Author: # Version: # COMP 1012 Abolfazl x Question y Stew Dent yyyy/mm/dd # Purpose: The purpose of the program. # # var1 - the use / meaning of each variable in the program Begin each program with the following statements. from time import ctime print('\n----- End each program with the following statements. Print(""" Programmed by Stew Dent Date: %s End of processing.""" % ctime()) Replace Stew Dent with your real name. The name of each program should be of the form: LastnameFirstnameAnQm If your name is Stew Dent and the program is for assignment 1 question 1 then the name of the program should be: DentStewA2Q1 The corresponding python file would be named: DentStewA2Q1.py -\n')
The purpose of this 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.
Use spyder Please take a screenshot and make sure the codes are working. Thank you
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am