Python Random Question
- by coson
Good Day,
I am using Python 2.6 and am trying to run a simple random number generator program (random.py):
import random
for i in range(5):
# random float: 0.0 <= number < 1.0
print random.random(),
# random float: 10 <= number < 20
print random.uniform(10, 20),
# random integer: 100 <= number <= 1000
print random.randint(100, 1000),
# random integer: even numbers in 100 <= number < 1000
print random.randrange(100, 1000, 2)
I'm now receiving the following error:
C:\Users\Developer\Documents\PythonDemo>python random.py
Traceback (most recent call last):
File "random.py", line 3, in <module>
import random
File "C:\Users\Developer\Documents\PythonDemo\random.py", line 8, in <module>
print random.random(),
TypeError: 'module' object is not callable
C:\Users\Developer\Documents\PythonDemo>
I've looked at the Python docs and this version of Python supports random. Is there something else I'm missing?
TIA,
coson