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 plusMinus(arr):
p,n,z=0,0,0
for i in range(len(arr)):
if arr[i]>0:
p+=1
elif arr[i]<0:
n+=1
else:
z+=1
print("{0:.6f}".format(p/len(arr)),'\n',"{0:.6f}".format(n/len(arr)),'\n',"{0:.6f}".format(z/len(arr)))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
def plusMinus(arr): p,n,z=0,0,0 for i in range(len(arr)): if arr[i]>0: p+=1 elif arr[i]<0: n+=1 else: z+=1 print("{0:.6f}".format(p/len(arr)),'\n',"{0:.6f}".format(n/len(arr)),'\n',"{0:.6f}".format(z/len(arr)))