From: Adam
Date: 02/19/06 18:25:05
Subject: Re: [Tutor] Generating small random integer
 
 
You might want to try the random module.
 
*****************************
Why did I get this diagnostic?
 
 
>>> factor0(3737)
[1, 0, 0, 3737, 1, 1, 3737, 1]
 
Traceback (most recent call last):
  File "<pyshell#50>", line 1, in -toplevel-
    factor0(3737)
  File "<pyshell#35>", line 12, in factor0
    v = transfac(v)
  File "<pyshell#48>", line 19, in transfac
    na = na + randint(1,na)
NameError: global name 'randint' is not defined
 
 
In the function that calls randint,   I placed the import command.
 
def transfac(v):
  import random
  a = v[0]
 
randint( a, b)
Return a random integer N such that a <= N <= b.

 
 
***********************

In general,  how can I find documentation on any particular function if I
don't know what module it is in?

do a search on http://www.python.org/

 
******************
 
 

Patch: 3-argument pow() function

 
 
I found this, but it doesn't tell me how to use it.
 
I wanted to write a pseudo prime number tester.
 
So,  I wanted to use this function to test the value of
 
pow(2,(z-1)/2,z)  for positive integers z.
 
 
*******
 
 
 
 
 
 
 
 
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to