Plus Minus

  • + 0 comments
    def plusMinus(arr):
        # Write your code here
        positive_count = 0
        negative_count = 0
        zero_count = 0
        total = len(arr)
    
        for num in arr:
            if num > 0:
                positive_count += 1
            elif num == 0:
                zero_count += 1
            else:
                negative_count += 1
    
        positive_avg = "{:.6f}".format(positive_count / total)
        zero_avg = "{:.6f}".format(zero_count / total)
        negative_avg = "{:.6f}".format(negative_count / total)
    
        print(positive_avg)
        print(negative_avg)
        print(zero_avg)