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.
n=int(input(''))
arr = list(map(int, input().split()))
def plusMinus(arr):
'''counts the number of positive and negative integers as well as zeros
'''
pos= 0
neg= 0
zero= 0
for i in arr:
if i > 0:
pos += 1
elif i < 0:
neg +=1
else:
zero += 1
return pos, neg, zero
arr_count = (plusMinus(arr))
for num in arr_count:
print(num/n)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Plus Minus
You are viewing a single comment's thread. Return to all comments →
n=int(input('')) arr = list(map(int, input().split())) def plusMinus(arr): '''counts the number of positive and negative integers as well as zeros ''' pos= 0 neg= 0 zero= 0 for i in arr: if i > 0: pos += 1 elif i < 0: neg +=1 else: zero += 1 return pos, neg, zero arr_count = (plusMinus(arr)) for num in arr_count: print(num/n)