Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Python: Getting Random Numbers

Python: Getting Random Numbers
{filelink=16768}

import random
for i in range(10):
    # random float: 0.0 <= number < 1.0
    print random.random(),
    # random float: 10 <= number < 50
    print random.uniform(10, 50),
    # random integer: 100 <= number <= 1000
    print random.randint(100, 1000),
    # random integer: even numbers in 100 <= number < 1000
    print random.randrange(100, 1000, 2)

Users who found this page were searching for:

  • python getting random numbers
  • how to output a random number in python gui

No comments yet.

Leave a Comment