Let us take a list of Numbers and generate the sum of the entire list by using sum
Numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print (sum(Numbers))
Output
55
Well, for sequence part of the question (1+2)/2, (2+3)/2, ..., (9+10)/2
use a generator and the formula (2*i-1)/2.
dot is used here to make the values in decimal or floating point.
The first element needs to be skipped when generating the new list
Solution = [(2*i-1)/2. for i in Numbers[1:]]
print(Solution)
Output
[1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]
print (sum(Solution))
Output
49.5