[Tutor] Random Number Generator
Jason Massey
jason.massey at gmail.com
Tue Dec 4 20:11:41 CET 2007
Easy enough. You'll want to import the random module and use the functions
in it. Also, http://docs.python.org/lib/lib.html is going to be your best
friend. You'll notice on that page among many other things is a section on
random number generation.
As to your code:
>>>import random
>>>a = random.randint(1,20)
>>>a
3
On Dec 4, 2007 12:56 PM, earlylight publishing <
earlylightpublishing at yahoo.com> wrote:
> Hello All,
>
> I'm a bare beginner to python (or indeed) any programming. I'm helping
> myself become more proficient by making a text adventure game. The problem
> is I need a function (or module) that will generate a random number within a
> range, say 1-20 for example. The ability to program this is beyond my
> meager abilities at the moment but I'd really like to get started. Would
> anyone out there be willing to provide me the code for me? Or at least
> point me in the right direction for finding it myself?
>
> TYIA
> :-)
>
> ------------------------------
> Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See
> how. <http://us.rd.yahoo.com/evt=51732/*http://overview.mail.yahoo.com/>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071204/e0662b91/attachment-0001.htm
More information about the Tutor
mailing list