Skip to content

Instantly share code, notes, and snippets.

@codeperfectplus
Last active September 13, 2023 03:45
Show Gist options
  • Save codeperfectplus/9dc3777e1fbf65357641748eb7890f32 to your computer and use it in GitHub Desktop.
Save codeperfectplus/9dc3777e1fbf65357641748eb7890f32 to your computer and use it in GitHub Desktop.
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)
if __name__ == '__main__':
n = int(input())
arr = list(map(int, input().rstrip().split()))
plusMinus(arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment