LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Python problems trying to generate a random number (https://www.linuxquestions.org/questions/programming-9/python-problems-trying-to-generate-a-random-number-108985/)

davholla 10-27-2003 04:07 AM

Python problems trying to generate a random number
 
I am trying to create a simple python progam that generates intergers asks the user what is interger1 x interger2 and records in a file if they got it right or not. It is to help my niece with her basic arithmetic.
Anyway the bit I am having problems with is generating the random number the code is :-

import random
import array
arr = []
n = Random.randint(0,100)
print n
(at the moment I am just trying the random bit, I think I can do the rest once this works)


and the errors are :-

Traceback (most recent call last):
File "ran.py", line 1, in ?
import random
File "/usr/lib/python2.2/random.py", line 752, in ?
_inst = Random()
File "/usr/lib/python2.2/random.py", line 132, in __init__
self.seed(x)
File "/usr/lib/python2.2/random.py", line 155, in seed
import time
File "time.py", line 2, in ?
print ctime
NameError: name 'ctime' is not defined


All times are GMT -5. The time now is 03:11 PM.