You're given an array containing integer values. You need to print the fraction of count of positive numbers, negative numbers and zeroes to the total numbers. Print the value of the fractions correct to 3 decimal places.
Input Format
First line contains \$N\$, which is the size of the array. Next line contains \$N\$ integers \$A_1, A_2, A_3, ⋯, A_N\$, separated by spaces.
Constraints
- \$1 \le N \le 100\$
- \$−100 \le A_{i} \le 100\$
Solution
from __future__ import division
N = int(raw_input())
ary = map(int, raw_input().split())
count_negatives = len(filter(lambda x: x < 0, ary))
count_positives = len(filter(lambda x: x >0, ary))
count_zeros = len(filter(lambda x: x == 0, ary))
print count_positives / N
print count_negatives / N
print count_zeros / N
It seems that this problem has a very straightforward solution but I am more interested if there is a better functional approach.