math library is only thing I can be used in this problem and this is what I done
ID: 3879267 • Letter: M
Question
math library is only thing I can be used in this problem and this is what I done so far,
I have errors, and I don't know how to fix it.
can someone help me?
Hint: the sqrt() function from the math library might be helpful for this. If you use a seperate file you need to load the library as we did in Part 1 to read in the data. The import looks like this: [41]: your code goes here import math temperature vector = a mean = float (sum(a)) / len (a) v-sum(pow(x - mean),2) for x in (a len (a) standard_deviation-math.sqrt(v) In File "", line 5 v sum(pow(x mean ) ,2) for x in (a) / len (a) = - SyntaxError: invalid syntaxExplanation / Answer
'''In 5th line, your way of iterating list is wrong so it is giving error to calculate squared differences you need to iterate a list and create a new list and then sum it so replace fifth line with below line of code v=sum([pow(x-mean,2) for x in a])/len(a) ''' #Complete code import math a=[3,3,6] mean=float(sum(a))/len(a) v=sum([pow(x-mean,2) for x in a])/len(a) print(math.sqrt(v))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.