lede-105-basic.py

Warning: WordPress won’t let me attach a .py or .txt file, so I’m copying it  onto this page. Indentations & other things may be off, so use as a reference only & be prepared to edit & debug.

# This script will generate a poem in the style of Nick Monfort’s Lede
# https://nickm.com/poems/lede.html
# adapted from https://gist.githubusercontent.com/robincamille/505ed5f678bc631e100a/raw/9bc7de08ed8a99446cd7787abe36361366b17c1d/mashup_madlib.py

# dependencies

from random import randint

gerundList = [“running”, “collating some printed documents” , “reading a book” , “setting an alarm clock” , “cheering on the team” ]
adjectiveList = [“tall”, “short”, “dazzling” , “voluminous” , “industrious” , “angular” ]
occupationsList = [“construction worker” , “mathematician” , “violist” , “numismatist” ]
monstersList = [“chimaera”, “cyclops” , “Godzilla” , “five-headed dragon” ]
verbList = [“play cards” , “roll dice” , “shake hands” , “recycle” , “pontificate”]
counter = 0

while counter < 1: # Change 2 to however many poems you want to produce

# Pick random numbers
gerundnum = randint(0, len(gerundList) – 1)
adj1num = randint(0, len(adjectiveList) – 1)
adj2num = randint(0, len(adjectiveList) – 1)
occnum = randint(0, len(occupationsList) – 1)
monstersnum = randint(0, len(monstersList) – 1)
verbnum = randint(0, len(verbList) – 1)

# Choose random items from each list using random numbers
gerund = gerundList[gerundnum] # Syntax: list[number]
adj1 = adjectiveList[adj1num]
adj2 = adjectiveList[adj2num]
occ = occupationsList[occnum]
monster = monstersList[monstersnum]
verb = verbList[verbnum]

# Fill in the blanks of the poem
poem = “While %s, an %s %s %s had an idea: why not dress as a %s and %s with people?” \
% (gerund, adj1, adj2, occ, monster, verb)

print(poem)
counter = counter + 1

print(“End poem”)