Python: Sum a list of numbers
Pairwise Average of List
Sum a list of numbers. Write a Python program to sum the first number with the second and divide it by 2, then sum the second with the third and divide by 2, and so on.
Equation: (element 0 + element 1) / 2, (element 1 + element 2) / 2, ... etc.
Visual Presentation:

Sample Solution:
Python Code:
Sample Output:
Original list: [1, 2, 3, 4, 5, 6, 7] Sum the said list of numbers: [1.5, 2.5, 3.5, 4.5, 5.5, 6.5] Original list: [0, 1, -3, 3, 7, -5, 6, 7, 11] Sum the said list of numbers: [0.5, -1.0, 0.0, 5.0, 1.0, 0.5, 6.5, 9.0]
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to compute pairwise averages of adjacent elements in a list and round the results to the nearest integer.
- Write a Python program to calculate the pairwise averages for a list of floating-point numbers and return a new list of these averages.
- Write a Python program to compute the difference between each consecutive pairwise average in a list.
- Write a Python program to compute pairwise averages and then filter out those averages that fall below a specified threshold.
Python Code Editor:
Previous: Write a Python program to find the common tuples between two given lists.
Next: Write a Python program to count the number of groups of non-zero numbers separated by zeros of a given list of numbers.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.