Advertisement
here2share

# random_module.py

Nov 1st, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. # random_module.py
  2.  
  3. from random import *
  4.  
  5. for x in range(10):
  6.     print random()
  7.  
  8. print '='*27
  9.  
  10. z = ['one', 'two', 'three', 'four', 'five', 'six']
  11.  
  12. for x in z:
  13.     # picks a random element from a list
  14.     print choice(z)
  15.  
  16. print '='*27
  17.  
  18. # randomly attach elements
  19.  
  20. for x in range(10):
  21.     shuffle(z)  # shuffle modifies the element in place so you have to call it beforehand
  22.     print " ".join(z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement