random number generator

Discussion in 'Python' started by questions?, Nov 3, 2005.

  1. questions?

    questions? Guest

    How to generate a random number in Python. Is there any build in
    function I can call?

    Thanks
     
    questions?, Nov 3, 2005
    #1
    1. Advertising

  2. Fredrik Lundh, Nov 3, 2005
    #2
    1. Advertising

  3. questions?

    avnit Guest

    import random
    print random.randint(1,20)

    #prints random integer from 1 to 20
     
    avnit, Nov 4, 2005
    #3
  4. questions?

    Bryan Olson Guest

    Fredrik Lundh wrote:
    >>How to generate a random number in Python. Is there any build in
    >>function I can call?

    >
    >
    > >>> import random
    > >>> help(random)


    If you need crypto-quality randomness:

    >>> import os
    >>> help(os.urandom)



    --
    --Bryan
     
    Bryan Olson, Nov 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kingsley Oteng

    Random Number Generator??

    Kingsley Oteng, Apr 27, 2004, in forum: VHDL
    Replies:
    11
    Views:
    53,030
    rahul.iyer
    Aug 9, 2010
  2. tshad

    Random number/letter generator

    tshad, May 5, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    9,608
    tshad
    May 6, 2005
  3. Wally
    Replies:
    1
    Views:
    2,839
    pvdg42
    Mar 20, 2006
  4. globalrev
    Replies:
    4
    Views:
    823
    Gabriel Genellina
    Apr 20, 2008
  5. VK
    Replies:
    15
    Views:
    1,336
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page