-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlus Minus
More file actions
42 lines (30 loc) · 859 Bytes
/
Copy pathPlus Minus
File metadata and controls
42 lines (30 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/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(list1):
pos_count, neg_count,zero = 0, 0, 0
# iterating each number in list
for num in list1:
# checking condition
if num >= 1:
pos_count += 1 #positive number
elif num == 0:
zero += 1 #counting zero's
else:
neg_count+=1 #negtive numbers
a=pos_count/len(list1)
b=neg_count/len(list1)
c=zero/len(list1)
print("{:.6f}\n{:.6f}\n{:.6f}".format(a,b,c)) #formating {:.6f} means 6 numbers after "."
if __name__ == '__main__':
n = int(input().strip())
arr = list(map(int, input().rstrip().split()))
plusMinus(arr)