Weighted Mean
Given a discrete set of numbers, , and a corresponding set of weights, , the weighted mean is calculated as follows: , where and are the respective corresponding elements of and .
For example, if and , our weighted mean would be:
If we wanted to round this to a scale of decimal place, our result would be .
num = int(input())
values = list(map(int, input().split()))
weights = list(map(int, input().split()))
v = list(map(lambda x, y: x*y, values, weights))
wmean= sum(v)/sum(weights)
print('%.1f' % wmean)
Last updated