Hey, I just recently (like 5 mins ago) showed you all my goofy sentence generator! Pretty cool eh? Lol just kidding its not all that great. Anyway, this thread will be for all of your programs that you want to share!
Format:
Program Name:
Description:
Link:
<Place code here>
Example (Using my goofy sentence generator):
Program Name: Goofy Sentence Generator!
Description: This program makes random goofy sentences based on 3 different parts.
Link: http://www.sendspace.com/file/h819ce
#This program is a goofy sentence generator.
import random
def make_sentence(part1, part2, part3, n=1):
"""return n random sentences"""
#convert to lists here.
p1 = part1.split('\n')
p2 = part2.split('\n')
p3 = part3.split('\n')
#shuffle the lists here.
random.shuffle(p1)
random.shuffle(p2)
random.shuffle(p3)
#concatinate the sentences here.
sentence = []
for k in range(n):
try:
s = p1[k] + ' ' + p2[k] + ' ' + p3[k]
s = s.capitalize() + '.'
sentence.append(s)
except IndexError:
break
return sentence
#break a typical sentence into 3 parts
#first part of a sentence (subject)
part1 = """\
a drunken sailor
a giggling goose
the yearning youth
the obese ostrich
this mean mouse
the skinny sister"""
#middle part of a sentence (middle)
part2 = """\
jumps over
flies over
runs across
openly ogles
twice tastes
vomits on"""
#ending part of a sentence (object)
part3 = """\
a rusty fence
the laughing cow
the weedcovered backyard
the timid trucker
the rancid old cheese
the jolly jelly"""
print '-'*60
sentence = make_sentence(part1, part2, part3, 3)
for item in sentence:
print item
print '-'*60
#A typical result would be this:
# A drunken sailor flies over the laughing cow.
#Now we use raw_input to be able to stop and look at the result.
raw_input("Press <enter> when you're done.")
So start sharing your programs you make! They can be helpful, stupid, cool, wierd, random, ANYTHING YOU WANT! Have fun guys!