import numpy as np

x = [8.0, 1, 2.5, 4, 28.0]
w = [0.05, 0.05, 0.05, 0.05, 0.8]
y = np.array(x)
################ weighted mean #################################

# using pure Python
wmean= sum(w[i] * x[i] for i in range(len(x))) / sum(w)
print("weighted mean: ", wmean)
print()

############ using numpy function ############

y, w = np.array(x), np.array(w)
wmean = np.average(y, weights=w)
print("weighted mean using numpy function: ",wmean)