
Benjamin T. answered 05/11/24
Physics Professor, and Former Math Department Head
To finish this problem you should be able to run Python from command line. That's where you will run this program. Search for a Youtube video if running Python from command line confuses you.
For the input you will need to request that from the user. That part of the code will look like this
#Start of code
import numpy as np #maybe?
response = input('Enter numbers:')
#End of this part of the code
Then you will need to the the response and convert the strings to floats. You could do something like this.
#Code continued
listOfStrings = response.split(' ')
listOfFloats = [float(x) for x in listOfStrings] #makes a list with a for loop, float changes the type
mean = sum(listOfFloats)/len(listOfFloats)
listOfDiffsSquared = [(x-mean)**2 for x in listOfFloats]
stdev = (sum(listOfDiffsSqured)/(len(listOfFloats)-1))**0.5
print('The mean is '+str(mean))
print('The standard deviation is '+str(stdev))
#end of code
Using Numpy
arrayOfFloats = np.array([float(x) for x in listOfStrings])
mean = np.mean(arrayOfFloats)
stdev = np.std(arrayOfFloats)
And that should be it. Don't feel discouraged if your code doesn't run the first time. If code runs the first time you should be suspicious.