[ create a new paste ] login | about

Project: python
Link: http://python.codepad.org/Bmpj3GY2    [ 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
19
20
21
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
print(pcount)
print(ncount)
print(zcount)
pcountfr=decimal(pcount/n)
ncountfr=decimal(ncount/n)
zcountfr=decimal(zcount/n)
print(pcountfr)
print(ncountfr)
print(zcountfr)


Output:
1
2
3
4
5
6
7
2
3
1
Traceback (most recent call last):
  Line 16, in <module>
    pcountfr=decimal(pcount/n)
NameError: name 'decimal' is not defined


Create a new paste based on this one


Comments: