Posted By

chrisaiv on 08/26/09


Tagged

python


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

louscomp


Python: Generate a random number


 / Published in: Python
 

  1. '''
  2. Dice Roller - Generate two pseudo-random numbers
  3. @author: chrisaiv
  4. '''
  5.  
  6. import random
  7.  
  8. die1 = random.randrange(6) + 1
  9. die2 = random.randrange(6) + 1
  10.  
  11. total = die1 + die2
  12.  
  13. print "You rolled a", die1, "and a", die2, "for a total of ", total

Report this snippet  

You need to login to post a comment.