document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. """
  2.     Generates 40 random numbers and writes them
  3.     to a file. No number is repeated.
  4.  
  5.     ~ Created by Elijah Wilson 2014 ~
  6. """
  7.  
  8. # used for generating random integers
  9. from random import randint
  10.  
  11. # open the output file -> "in.data"
  12. f = open("in.data", "w")
  13.  
  14. # create an empty list
  15. succ = []
  16.  
  17. # loops through 40 times for generating numbers
  18. for x in xrange(0,40):
  19.     # generate random int between 1111 & 9999
  20.     randNum = randint(1111, 9999)
  21.  
  22.     # check to see if it was already generated
  23.     if randNum not in succ:
  24.         # put the random number in the list
  25.         succ.append(str(randNum))
  26.     else:
  27.         # while the randNum has already been generated
  28.         # generate a new one
  29.         while randNum in succ:
  30.             randNum = randint(1111, 9999)
  31.         # put the random number in the list
  32.         succ.append(str(randNum))
  33.  
  34. # loops through 40 times for writing to file
  35. for x in xrange(0,40):
  36.     # makes sure it isn\'t the last line to be written
  37.     # to write a new line char
  38.     if x != 39:
  39.         f.write(succ[x] + "\\n")
  40.     else:
  41.         # if it is the last line to be written
  42.         # don\'t write a new line char
  43.         f.write(succ[x])
  44.  
  45. #close the file
  46. f.close()
');