Created
September 13, 2023 03:47
-
-
Save codeperfectplus/bb403ba374ca5fc183a15577fd57361d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plusMinus(arr): | |
countPositive = 0 | |
countNegative = 0 | |
n = len(arr) | |
for i in range(n): | |
if arr[i] > 0: | |
countPositive += 1 | |
elif arr[i] < 0: | |
countNegative += 1 | |
countZero = n - countPositive-countNegative | |
print(countPositive/n) | |
print(countNegative/n) | |
print(countZero/n) | |
def test_case_0(): | |
arr = [-4, 3, -9, 0, 4, 1] | |
plusMinus(arr) | |
test_case_0() | |
# output | |
# 0.5 | |
# 0.3333333333333333 | |
# 0.16666666666666666 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment