Running average

Report a typo

Read a string with digits from the input and convert each number of the string to an integer. For your newly created list, calculate the running average according to the following formula:

Ai=xi+xi+12,A_i = \frac{x_i + x_{i+1}}{2}, where xix_i and xi+1x_{i+1} are elements of the original list, AiA_i is the element of the moving average. For instance, if your string is 123, an average of 1 and 2 will be 1.5, and an average of 2 and 3 will be 2.5.

Print the result. Notice that this list will have one less item.

Sample Input 1:

12345

Sample Output 1:

[1.5, 2.5, 3.5, 4.5]
Write a program in Python 3





___

Create a free account to access the full topic