Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import random
  2. import sys
  3.  
  4. # opening file
  5. #f = open("astronomy.txt", "r") # uncomment if not using command line for run script
  6.  
  7. words = list()
  8.  
  9. # iterating through lines in corpus, breaking into lines, filling "words" list with lines from corpus
  10. for token in sys.stdin:
  11. token = token.strip()
  12. words.append(token)
  13.  
  14. # randomly choosing a line from source corpus
  15. selection = random.choice(words)
  16.  
  17.  
  18. # assigning variables with both pre-determined and dynamic string values
  19. first = "Then, "
  20. middle = str(selection)
  21. last = ". Just like today."
  22.  
  23.  
  24. print first + middle + last
  25.  
  26.  
  27. # closing file
  28. #f.close() # unncomment for non-command line use cases
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement