Help with if statement

Jikosan jikosan83 at yahoo.com
Sun Jan 11 07:01:58 CET 2004


I can't get my "if" statement to work indicated below.
What happens is no matter what the value random is, neg gets incremented by 1.

This is actually my first time programming in Python. Any help is appreciated.

TIA
Gene

import random
uniform = random.uniform
neg = 0
N = int(raw_input("Enter number of random generations, N: "))

for x in range(0,N):
    random = uniform(-1, 1)
    print random
    if random < 1.0: <--- Not working
        neg = neg+1
print neg
pi = 4.*(neg/N)
print 'The value of Pi is ', pi



More information about the Python-list mailing list