def placeBet(cash): bet = Epic.userInt("How much would do you want to bet? (cash: $%s) " % cash) while bet > cash: print "You don't have that much money!" bet = Epic.userInt("How much would do you want to bet? (cash: $%s) " % cash) return bet
def main(): ans = random.randrange(1, 11) keepGoing = True while keepGoing: guess = Epic.userInt("Enter a guess from 1 to 10:") if guess == ans: print "You win!" keepGoing = False
def main(): d = build_deck(rank, suit) times = Epic.userInt( "How many times would you like the deck to be shuffled?:") for i in range(0, times): d = shuffle(d) print deal(d)
def main(): deck = buildDeck(rank, suit) number = Epic.userInt("How many times do you want to shuffle? ") for i in range(0, number): deck = shuffle(deck) deck = deal(deck) print deck
def main(): numGuesses = 0 ans = random.randrange(1, 11) keepGoing = True while keepGoing: guess = Epic.userInt("Enter a guess from 1 to 10:") numGuesses = numGuesses + 1 if guess == ans: print "You win! It took %s guesses." % numGuesses keepGoing = False else: if (guess > ans): print "You guessed too high!" else: print "You guessed too low!"
def main(): good_prizes = ["New Car!", "$100", "A Badge in Pyhton Class", "A free A in python!"] bad_prizes = ["An Old Sock", "A Smelly Garbage Can", "A Sore Throat", "More Homework"] doors = ['', '', ''] #place random bad prizes between all 3 doors random.shuffle(bad_prizes) doors[0] = bad_prizes[0] doors[1] = bad_prizes[1] doors[2] = bad_prizes[2] #replace random bazd prize with good one random.shuffle(good_prizes) iGoodPrize = random.randrange(0,3) doors[iGoodPrize] = good_prizes[0] #let user pick door door = Epic.userInt("Pick a door:") print "You win..." time.sleep(5) print "You win a %s" % doors[door-1]
def main(): # initialize prizes... good_prizes = ["New Car!", "$100", "Badge in Python Class", "Free A in Python!"] bad_prizes = ["Old Sock", "Smelly Garbage Can", "Sore Throat", "More Homework"] # create a list for the doors... doors = ["", "", ""] # place radom bad prizes in behind all three doors... random.shuffle(bad_prizes) doors[0] = bad_prizes[0] doors[1] = bad_prizes[1] doors[2] = bad_prizes[2] # replace a random bad prize with a good one... random.shuffle(good_prizes) iGoodPrize = random.randrange(0,3) doors[iGoodPrize] = good_prizes[0] # let the user pick a door door = Epic.userInt("Pick a door:") print "You win..." time.sleep(5) print "...a %s" % doors[door-1]
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
# Song Creator # A program to asist user in constructing a song # By Tim Murphy 15/7/17 import Epic verseNum = ["first", "second", "third", "fourth"] verseList = [] # Acquiring submissions of each verse from user and adding to list for verse in verseNum: userVerses = Epic.userString("Enter your %s verse:" % verse) verseList.append(userVerses) chorus = Epic.userString("Enter your chorus:") repeat = Epic.userInt("Enter your repeat amount:") fullChorus = (chorus + "") * repeat lastChorus = fullChorus + chorus # Pairing choruses with each verse verseList.insert(1, fullChorus) verseList.insert(3, fullChorus) verseList.insert(5, fullChorus) verseList.insert(7, lastChorus) verseList.insert(8, "One More Time Now!") song = verseList * 2 del song[17] print song