Created
December 1, 2016 14:35
-
-
Save alexanderankin/cf2a44d12e2d3ee42ebe6a3c533e6830 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| NOUNS = [ "wings", "flowers", "Uggs", "bees", "tomatoes", "carrots", "teeth" ] | |
| VERBS = [ "shoot", "fall", "walk", "jump", "butcher", "swim", "sleep", "dive" ] | |
| ADJECTIVES = [ "ugly", "blue", "tart", "smelly", "yellow", "fleshy" ] | |
| ADVERBS = [ "anxiously", "willfully", "angrily", "happily", "grossly", "hungrily"] | |
| def makeSentence(): | |
| a = random.choice(ADJECTIVES) | |
| n = random.choice(NOUNS) | |
| v = random.choice(VERBS) | |
| ad = random.choice(ADVERBS) | |
| sentence = " ".join([a, n, v, ad]) | |
| sentence = " The " + sentence + ".\n" | |
| # print sentence | |
| return sentence | |
| def saveSentence(sentence, handle): | |
| if handle.closed: return; | |
| handle.write(sentence) | |
| fn = "output.txt" | |
| fh = open(fn, 'w') | |
| for i in range(5): | |
| saveSentence(str(i) + " " + makeSentence(), fh) | |
| fh.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment