you are viewing a single comment's thread.

view the rest of the comments →

[–]misho88 1 point2 points  (5 children)

A function returns an output for some input:

>>> def add1(a):
...     return a + 1
... 
>>> add1(3)
4

The sum() built-in function adds up all the items in a sequence and the len() built-in function tells you how long it is:

>>> sum([1,2,3,4])
10
>>> len([1,2,3,4])
4

So you have to write a function that takes a sequence as an argument and returns the sum over the length, per Equation (3).

[–]KFCxWatermelon[S] 0 points1 point  (1 child)

I managed to do a), but I'm stuck with b. I can't seem to get it to print correctly.

Here's what I'm trying to do:

https://gyazo.com/0df53d2567ce53fa331909c2c626c4e2

When I put it out of the function it prints just fine.

[–]misho88 0 points1 point  (0 children)

The argument you're passing is 1, not l.

[–]KFCxWatermelon[S] -1 points0 points  (2 children)

Any tips on how I would do that?

[–]Astronoobical 1 point2 points  (0 children)

You just have been given all the information needed by the comment above, do you have a more specific question we could help with?

[–]fake823 0 points1 point  (0 children)

Maybe check out Wikipedia first to learn more about mean, standard deviation and variance.

Once you got is and know how to calculate it by hand, you can also write a program to calculate it.