Plus Minus

Sort by

recency

|

289 Discussions

|

  • + 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)
    
  • + 0 comments

    1 (0)n>

  • + 0 comments

    1 (0)n>

  • + 0 comments

    aviator Signals

  • + 0 comments

    !/bin/python3

    import math import os import random import re import sys

    #

    Complete the 'plusMinus' function below.

    #

    The function accepts INTEGER_ARRAY arr as parameter.

    #

    def plusMinus(arr): # Write your code here n=len(arr) positive=sum(1 for x in arr if x>0) negative=sum(1 for x in arr if x<0) zero=sum(1 for x in arr if x==0) print(f"{positive / n:.6f}") print(f"{negative / n:.6f}") print(f"{zero / n:.6f}")

    if name == 'main': n = int(input().strip())

    arr = list(map(int, input().rstrip().split()))
    
    plusMinus(arr)