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.
def plusMinus(arr):
# Write your code here
l = len(arr)
p = sum(map(count_positive, arr))
n = sum(map(count_negative, arr))
z = sum(map(count_zero, arr))
print(f"{p/l:.6f}")
print(f"{n/l:.6f}")
print(f"{z/l:.6f}")
if name == 'main':
n = int(input().strip())
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 count_positive(a): return int(a > 0) def count_negative(a): return int(a < 0) def count_zero(a): return int(a == 0)
def plusMinus(arr): # Write your code here l = len(arr) p = sum(map(count_positive, arr)) n = sum(map(count_negative, arr)) z = sum(map(count_zero, arr)) print(f"{p/l:.6f}") print(f"{n/l:.6f}") print(f"{z/l:.6f}") if name == 'main': n = int(input().strip())