Search This Blog

Monday, June 15, 2009

Python Random Number

#DO NOT NAME THIS FILE random.py
#BECAUSE WE TRY TO IMPORT random here!

import random

#[0.0, 1.0), does not include 1
print random.random()

#[1or2or3or4or5or6]
print random.randint(1,6)

#[1or3or5or7or9]
aList = [1,3,5,7,9]
print random.choice(aList)

#note:emacs multiple yank: C-y, M-y

No comments: