# Python code to find average of each consecutive segment# List initialisation
Input =[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]# Defining Splits
splits =5# Finding average of each consecutive segment
Output =[sum(Input[i:i + splits])/splits
for i inrange(len(Input)- splits +1)]# printing outputprint(Output)
# Python code to find average of each consecutive segment# Importingfrom statistics import mean
from itertools import islice
# List initialisation
Input =[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]# Finding average of each consecutive segment
zip_list =zip(*(islice(Input, i,None)for i inrange(5)))
Output =list(map(mean, zip_list))# printing outputprint(Output)