We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def weightedMean(X, W):
# Write your code here
we = [(x*w) for x,w in zip(X,W)]
weight = 0
for item in we:
weight += item
print(round(weight/sum(W),1))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 0: Weighted Mean
You are viewing a single comment's thread. Return to all comments →
def weightedMean(X, W): # Write your code here we = [(x*w) for x,w in zip(X,W)] weight = 0 for item in we: weight += item print(round(weight/sum(W),1))