I´m a girl form Germany and I need your help.
I have to do a task for university and I´m trying for hours, but it
never works :/. Maybe you can help me. I would be so happy!
The task is to make a function called “mean(a)”, for this function we
take a array we can build by ourselves, for example a = [1,4,5,7]. So
this function should summ up the elements of the array (for example 1 +
4 + 5 + 7] and then divide this sum with the count of the members (in
this example 4) --> sum/count --> also called mean. The function should
return the mean. So far i got it. But then we also should be prepared
for the case that there are no elements in the array then the function
should return “0”. But that´s what I don´t understand. We must do it all
with a loop. And I don´t understand this. The result should also be a
This is what I got so far:
a = [1,2,3,4,]
count = 0
summe = 0
for x in a
count += 1
summe += x
Would be so nice to help me.