November 23, 2024, 12:34:13 am

Author Topic: Program's Thread  (Read 2190 times)

0 Members and 1 Guest are viewing this topic.

Spartan

  • Follow my Twitter!
  • Champion Member
  • ***
  • Posts: 1792
  • I'm back
    • View Profile
Program's Thread
« on: March 12, 2011, 11:31:11 pm »
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:
Quote
Program Name:

Description:

Link:

Code: [Select]
<Place code here>

Example (Using my goofy sentence generator):
Quote
Program Name: Goofy Sentence Generator!

Description: This program makes random goofy sentences based on 3 different parts.

Link: http://www.sendspace.com/file/h819ce

Code: [Select]
#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!

Terrewee

  • Hero Member
  • **
  • Posts: 758
  • The Saint
    • View Profile
Re: Program's Thread
« Reply #1 on: March 13, 2011, 01:58:16 pm »
i use Auto Hotkey, it's basicly a program that does stuff when you press certant key combos.
i use it for macros and starting up minecraft
(it's for lazy ppl)


(click to show/hide)
Touhou~