the is a question about python programming how to calculate

the is a question about python programming

how to calculate the average value per 12 items in the list and convert the list to a new list?

for example I have a list [3, 3, 6, 2, 5, 8], I need to calculate the average value per 3 items, then the new list is [mean(3,3,6),mean(2,5,8)]

if I have 1008 items in the list, how to convert the list to a new list with 84 items?

Solution

l list of elements -user-defined/ or declare an arraysize for list
l = [15, 18, 2, 36, 12, 78, 5, 6, 9]
list m = sum(l) / float(len(l)) divide the sum of elents by the length of the list to get average

store the average in list m

the is a question about python programming how to calculate the average value per 12 items in the list and convert the list to a new list? for example I have a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site