<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="IncrediMail 1.0" name=GENERATOR></HEAD>
<BODY style="BACKGROUND-POSITION: 0px 0px; FONT-SIZE: 12pt; MARGIN: 5px 10px 10px; FONT-FAMILY: Arial" bgColor=#ffffff background="" scroll=yes ORGYPOS="0">
<TABLE id=INCREDIMAINTABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
<TBODY>
<TR>
<TD id=INCREDITEXTREGION style="FONT-SIZE: 12pt; CURSOR: auto; FONT-FAMILY: Arial" width="100%">
<DIV> </DIV>
<DIV> </DIV>
<DIV id=receivestrings>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>From:</B></I> <A href="mailto:adam.jtm30@gmail.com">Adam</A></DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>Date:</B></I> 02/19/06 18:25:05</DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>To:</B></I> <A href="mailto:kermit@polaris.net">Kermit Rose</A></DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>Cc:</B></I> <A href="mailto:tutor@python.org">tutor@python.org</A></DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>Subject:</B></I> Re: [Tutor] Generating small random integer</DIV></DIV>
<DIV> </DIV>
<DIV class=gmail_quote style="MARGIN: 0pt 0pt 0pt 0.8ex; rem_border-left: 1px solid rgb(204, 204, 204); rem_padding-left: 1ex"> </DIV>
<DIV class=gmail_quote style="MARGIN: 0pt 0pt 0pt 0.8ex; rem_border-left: 1px solid rgb(204, 204, 204); rem_padding-left: 1ex">You might want to try the <A href="http://www.python.org/doc/2.4.2/lib/module-random.html">random module.</A></DIV>
<DIV> </DIV>
<DIV>*****************************</DIV>
<DIV>Why did I get this diagnostic?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>>>> factor0(3737)<BR>[1, 0, 0, 3737, 1, 1, 3737, 1]</DIV>
<DIV> </DIV>
<DIV>Traceback (most recent call last):<BR> File "<pyshell#50>", line 1, in -toplevel-<BR> factor0(3737)<BR> File "<pyshell#35>", line 12, in factor0<BR> v = transfac(v)<BR> File "<pyshell#48>", line 19, in transfac<BR> na = na + randint(1,na)<BR>NameError: global name 'randint' is not defined</DIV>
<DIV><!--StartFragment --> </DIV>
<DIV> </DIV>
<DIV>In the function that calls randint, I placed the import command.</DIV>
<DIV> </DIV>
<DIV>def transfac(v):<BR> import random<BR> a = v[0]</DIV>
<DIV> </DIV>
<DT>
<TABLE cellSpacing=0 cellPadding=0>
<TBODY>
<TR vAlign=baseline>
<TD><NOBR><B><TT class=function id=l2h-1304 xml:id="l2h-1304">randint</TT></B>(</NOBR></TD>
<TD><VAR>a, b</VAR>)</TD></TR></TBODY></TABLE></DT>
<DD>Return a random integer <VAR>N</VAR> such that <CODE><VAR>a</VAR> <= <VAR>N</VAR> <= <VAR>b</VAR></CODE>.</DD>
<DIV><BR></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>***********************</DIV>
<DIV><BR></DIV>
<DIV class=gmail_quote style="MARGIN: 0pt 0pt 0pt 0.8ex; rem_border-left: 1px solid rgb(204, 204, 204); rem_padding-left: 1ex">In general, how can I find documentation on any particular function if I <BR>don't know what module it is in?</DIV>
<DIV><BR>do a search on <A href="http://www.python.org/">http://www.python.org/</A></DIV>
<DIV><BR></DIV>
<DIV> </DIV>
<DIV>******************</DIV>
<DIV> </DIV>
<DIV><!--StartFragment -->
<H1>Patch: 3-argument pow() function</H1>
<DIV> </DIV>
<DIV> </DIV>
<DIV>I found this, but it doesn't tell me how to use it.</DIV>
<DIV> </DIV>
<DIV>I wanted to write a pseudo prime number tester.</DIV>
<DIV> </DIV>
<DIV>So, I wanted to use this function to test the value of</DIV>
<DIV> </DIV>
<DIV>pow(2,(z-1)/2,z) for positive integers z.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>*******</DIV></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></TD></TR>
<TR>
<TD id=INCREDIFOOTER width="100%">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD width="100%"></TD>
<TD id=INCREDISOUND vAlign=bottom align=middle></TD>
<TD id=INCREDIANIM vAlign=bottom align=middle></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML>