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.
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}")
Plus Minus
You are viewing a single comment's thread. Return to all 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())