Example #1
0
def main():
    answer = ""
    eater1 = 0
    eater2 = 0
    eater3 = 0

    guess = Epic.userStr("Pick a winner (Tom, Sally, or Fred):")
    print "Ready.. Set.. Eat!"

    while answer == "":  # connects back to winner function
        eater1 = eater1 + random.randrange(1, 6)
        eater2 = eater2 + random.randrange(1, 6)
        eater3 = eater3 + random.randrange(1, 6)
        print
        for x in range(
                0,
                3):  # print this 3x instead of printing each one word for word
            print "chomp..",
        print
        time.sleep(1)  # let 2 secs pass between.
        print
        print "Tom has eaten %s hot dogs." % eater1
        print "Sally has eaten %s hot dogs." % eater2
        print "Fred has eaten %s hot dogs." % eater3
        answer = winner(eater1, eater2, eater3)

    print_winner(guess, answer)
Example #2
0
def askUser():
    d = {}
    for line in open("birds.txt"):
        temp = line.split(",")
        bird = temp[0].strip()
        sightings = int(temp[1].strip())
        if bird in d:
            d[bird] = d[bird] + sightings
        else:
            d[bird] = sightings

    bird = Epic.userStr("Enter a bird name:")
    if bird in d:
        return d[bird]
Example #3
0
import Epic

sentence = Epic.userStr("Please enter a sentence:")
words = sentence.split(' ')
lgWords = []
smWords = []

for word in words:
    if len(word) > 3:
        lgWords.append(word)
    else:
        smWords.append(word)

print words
print
print smWords
print
print lgWords
import Epic

song = []

verse1 = Epic.userStr("Enter the first verse here:")
verse2 = Epic.userStr("Enter the second verse here:")
verse3 = Epic.userStr("Enter the third verse here:")
verse4 = Epic.userStr("Enter the fourth verse here:")

chorus = Epic.userStr("Enter the chorus:")
chorusrep = Epic.userInt("Enter the chourus repeat:")
print

v = [verse1, verse2, verse3, verse4]
for x in v:
    song.append(x)
    song.append(chorus * chorusrep)
song.append(chorus)

song = (song * 2)
song.insert(8, "...one more time!...")

print song
print

for line in song:
    print line
Example #5
0
def main():
    word = Epic.userStr("Enter word here:")
    dictionary = findWord(word)
    printWord(dictionary)
# Andres Villasmil Ocando
# [email protected]
# Assignment 4: Bird Counts

# going to use user string after prompt
import Epic

# make an open dictionary
d = {}
for line in open("birds.txt"):
    temp = line.split(",")  # split by a comma
    birds = temp[0].strip()
    sightings = int(temp[1].strip())  # integer value of sightings
    if birds in d:
        d[birds] = d[
            birds] + sightings  # add number of sightings if it already exists
    else:
        d[birds] = sightings  # make that number the number of sightings

n = Epic.userStr("Enter a bird name:")  # entering user's prompt

# what the user wants to read.
if n in d:
    print "I've seen that bird %s time(s)." % d[n]
else:
    print "I've seen that bird 0 time(s)."