Jun-24-2024, 06:31 PM
Hi,
Here's what i want to do. I tried in C# but was wondering if it would not be more pratical in Python.
I have a serie of numbers: var Quodown = new List<int>() {9,7,6,9,7,6,4,3,0}; or if you prefer in python list = [9,7,6,9,7,6,4,3,0]
I am summing the numbers backward: 0+3 =3 than 0+3+4 = 7 ...
(3 + 0) / 2 = 1.5
(4 +3 +0) / 3 = 2.333
etc
I suppose i shoud recycle the i and make a nested for loop but its not working.
Thank you
Here's what i want to do. I tried in C# but was wondering if it would not be more pratical in Python.
I have a serie of numbers: var Quodown = new List<int>() {9,7,6,9,7,6,4,3,0}; or if you prefer in python list = [9,7,6,9,7,6,4,3,0]
I am summing the numbers backward: 0+3 =3 than 0+3+4 = 7 ...
for (int i = 8; i < Quodown.Count; i--) { sumi += Quodown[i]; Print("sumi: "+ sumi); //Print(i); }Now i want a moving average of each numbers i summed in the first loop.
(3 + 0) / 2 = 1.5
(4 +3 +0) / 3 = 2.333
etc
I suppose i shoud recycle the i and make a nested for loop but its not working.
for (int y = i; y < 8; y++) {avg = sumi / y; Print(y); }
Output:sumi: 0
sumi: 3
7 // it must divide by the number of elements but it is not counting the elements just returning the position of the element
sumi: 7
6
7
sumi: 13
5 // actually it should be 3 , 2 , 1
6
7
sumi: 20
4 // 4,3,2,1
5
6
7
Any help?Thank you