[ create a new paste ] login | about

Project: python
Link: http://python.codepad.org/QBZ8eX5J    [ raw code | output | fork ]

Python, pasted on Oct 11:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pcount=0
ncount=0
zcount=0
arr=[1,2,-1,-2,0,-3]
n=len(arr)
for i in range(0,n):
    if(arr[i]>0):
        pcount=pcount+1
    elif(arr[i]<0):
        ncount=ncount+1
    else:
        zcount=zcount+1
pcountfr=float(pcount/n)
ncountfr=float(ncount/n)
zcountfr=float(zcount/n)
print(pcountfr)
print(ncountfr)
print(zcountfr)


Output:
1
2
3
0.0
0.0
0.0


Create a new paste based on this one


Comments: