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.
#!/bin/python3importmathimportosimportrandomimportreimportsysimportmath## Complete the 'weightedMean' function below.## The function accepts following parameters:# 1. INTEGER_ARRAY X# 2. INTEGER_ARRAY W#defweightedMean(X,W):# Write your code hereres=[]foriinrange(0,len(X)):res.append(X[i]*W[i])print(round(sum(res)/sum(W),1))if__name__=='__main__':n=int(input().strip())vals=list(map(int,input().rstrip().split()))weights=list(map(int,input().rstrip().split()))weightedMean(vals,weights)
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 →