Question: The below explanations cover all steps that are required to perform the calculations for each function. However, some of those steps are already been implemented
The below explanations cover all steps that are required to perform the calculations for each function. However, some of those steps are already been implemented for you. Please fill in only the steps that are left incomplete.Instructions Function Definitions: You are provided with four incomplete functions in the codecalculatemeannumbers: calculate the mean average of a list of numbers.calculatemediannumbers: calculate the median middle number of a list of numbers.calculatestandarddeviationnumbers: calculate the standard deviation of a list of numbers.readfilefilename: read the file, put numbers in the file to a list, and return the list containing numbers.main: execute all functions and present results.Your task is to complete these functions by filling in the missing code. Do not use hardcoded values; instead, use Python code to perform the calculations. Also, you should not use any builtin functions for mean, median, and standard deviation. You should develop those functions from scratch based on the skeleton code Mean Calculation calculatemeannumbers function:Find the sum of all the numbers in the numbers list and store it in the variable sumnumbers.Find the length of the numbers list and store it in the variable lengthnumbers.Calculate the mean using the formula: mean sumnumbers lengthnumbers.Round the mean to two decimal places using the round function.Return the calculated mean to two decimal places Median Calculation calculatemediannumbers function:Sort the numbers list in ascending order and store it in the variable sortednumbers.Find the length of the numbers list and store it in the variable lengthnumbers.Calculate the index of the middle number in the sortednumbers list and store it in the variable middleindex. In other words, divide the length of the numbers and round it down. For instance, will be the mid index when there are numbers, and will be the mid index when there are numbers. You can use the floor function from the math library.If the length of the list is even ie lengthnumbers calculate the median using the formula: sortednumbersmiddleindex sortednumbersmiddleindexIf the length of the list is odd, simply return the middle number sortednumbersmiddleindex Standard Deviation Calculation calculatestandarddeviationnumbers:Calculate the mean of the numbers list by calling the calculatemeannumbers function and storing the result in the variable numbersmean.Find the length of the numbers list and store it in the variable lengthnumbers.Initialize a variable sumofsquareddistance to Iterate through each number in the numbers list:Calculate the distance of the current number to the mean distanceCalculate the square of the distance squareddistanceAdd the squared distance to sumofsquareddistance.Calculate the standard deviation using the formula: stddev sumofsquareddistance lengthnumbers Round the standard deviation to two decimal places using the round function.Return the calculated standard deviation File Processing readfilefilename:Read the file given as an argument to the function.Read each line of the file and convert them to floating numbers.Put numbers in the file to a list by using the append methodReturn the list containing numbers.PLEASE UTILIZE THE BELOW SKELETON CODE BY FILLING IN THE MISSING CODE:def calculatemeannumbers: # do not use hardcoded values; only code. sumnumbers # find the sum of the "numbers" list. lengthnumbers # find the length of the "numbers" list. mean sumnumbers lengthnumbers return roundmeandef calculatemediannumbers: # do not use hardcoded values; only code. sortednumbers # sort the numbers list ascendingly. lengthnumbers # find the length of the "numbers" list. middleindex math.floor # find the index of the middle number in the "sortednumbers" list. if lengthnumbers : return sortednumbersmiddleindex sortednumbersmiddleindex else: # return the middle number from the "sortednumbers" list. def calculatestandarddeviationnumbers: # do not use hardcoded values; only code. # requires to complete "calculatemean" function numbersmean calculatemeannumbers lengthnumbers # find the length of the "numbers" list. sumofsquareddistance for number in numbers: distance # calculate the distance of "number" to the mean ie "numbersmean" squareddistance # calculate the square of "distance" sumofsquareddistance squareddistance stddev sumofsquareddistances lengthnumbers return roundstddev, def readfilefilename: numbers list # an empty list where all numbers from the file will be stored. # Read the file given as an argument to the function. # Read each line of the file, convert them to floating numbers, and put numbers in the file to the "numbers" list by using the append method # Return the list containing numbers.def main: filename inputPlease enter the name of the input data file:" numbers readfilefilename mean calculatemeannumbers median calculatemediannumbers sd calculatestandarddeviationnumbers ## Present the results like the sample outputmain
PLEASE WRITE THE FOLLOWING PROGRAM USING PYTHON AND INCLUDE A SAMPLE INPUT AND OUTPUT, THANK YOU!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
