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.

defplusMinus(arr):# Complete this functionpositive=sum(x>0forxinarr)/len(arr)negative=sum(x<0forxinarr)/len(arr)zero=sum(x==0forxinarr)/len(arr)print(positive,negative,zero,sep="\n")

## Plus Minus

You are viewing a single comment's thread. Return to all comments →

In Python3 passes all test cases

Very nice. Simple and readable. You can also make it even shorter by printing the calculation directly without assigning it to a variable.

you can get an array length from "n" variable