t441.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import random
  2. print "\nrandom.seed([x])"
  3. random.seed(1234); print random.random()
  4. random.seed(5678); print random.random()
  5. random.seed('hello'); print random.random()
  6. random.seed((1,2,3,4)); print random.random()
  7. random.seed("world"); print random.random()
  8. random.seed((5,6,7,8)); print random.random()
  9. random.seed(""); print random.random()
  10. random.seed(()); print random.random()
  11. print "\nrandom.randrange([start],stop[,step])"
  12. random.seed(1)
  13. print random.randrange(100)
  14. print random.randrange(90,100)
  15. print random.randrange(10,101,10)
  16. print "\nrandom.randint(a,b)"
  17. print random.randint(1,100)
  18. print random.randint(-10,0)
  19. print "\nrandom.choice(seq)"
  20. print random.choice([1,2,3,4,5])
  21. print random.choice("hello world")
  22. print random.choice((1,2,3,4,5))
  23. print "\nrandom.shuffle(x[,random])"
  24. l = [1,2,3,4,5]
  25. random.shuffle(l); print l
  26. random.shuffle(l); print l
  27. random.shuffle(l); print l
  28. random.shuffle(l); print l
  29. random.shuffle(l); print l
  30. print "\nrandom.random()"
  31. print random.random()
  32. print random.random()
  33. print random.random()
  34. print random.random()
  35. print random.random()