Write a program to implement geometry distribution in python.


#Python program for Geometry
m = 16
a = 5
c = 3
z = 7
mylst = []
count = []
print "Random Numbers are : "
for num in range(m):
    r = (a * z + c) % m
    z = r
    mylst.append(float(z) / m)

print mylst

def test(w):
    count = 0

    for i in w:
        #print mylst[0], " ", i
        if mylst[0] <= i:
            count += 1
        else:
            break
    return count

p = []
f = input("Enter how many numbers : ")
print "Enter ",f, " numbers : "
for i in range(f):
    j = input("")
    p.append(float(j))

l = len(p)

c = test(p)

#print c, " ", l

print "Result Ratio is : "
print float(c) / float(l)


#--------------Output---------------

Enter how many numbers : 5
Enter  5  numbers :
.78
.34
.23
.67
.23
Result Ratio is :
0.2

No comments:

Post a Comment