Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def bear_game():
- print "You enter a dark room with two doors. Do you go through door #1 or door #2?"
- door = raw_input("> ")
- if door == "1":
- print "There's a giant bear here eating a cheese cake. What do you do?"
- print "1. Take the cake."
- print "2. Scream at the bear."
- bear = raw_input("> ")
- if bear == "1":
- random_number_game()
- elif bear == "2":
- random_number_game()
- else:
- print "Well, doing %s is probably better. Bear runs away." % bear
- elif door == "2":
- print "You stare into the endless abyss at Cthulhu's retina."
- print "1. Blueberries."
- print "2. Yellow jacket clothespins."
- print "3. Understanding revolvers yelling melodies."
- insanity = raw_input("> ")
- if insanity == "1" or insanity == "2":
- print "Your body survives powered by a mind of jello. Good job!"
- else:
- print "The insanity rots your eyes into a pool of muck. Good job!"
- else:
- print "You stumble around and fall on a knife and die. Good job!"
- bear_game()
- def transaction_number_generator():
- global transaction_number # can be acessed in other
- sequence_letter_one = random.choice(['a','b','c','d','e','f','g'])
- sequence_letter_two = random.choice(['a','b','c','d','e','f','g'])
- sequence_letter_three = random.choice(['a','b','c','d','e','f','g'])
- sequence_number_one = random.choice(['1','2','3','4','5','6','7','8','9','0'])
- sequence_number_two = random.choice(['1','2','3','4','5','6','7','8','9','0'])
- transaction_number = "%s%s%s%s%s" % (sequence_letter_one,sequence_letter_two,sequence_number_one,sequence_letter_three,sequence_number_two)
- transaction_number_generator()
- def random_number_game():
- import random # import random
- global random_number
- random_number = random.choice(range(1, 51)) # Generating random number
- def name_input():
- global user_name # so name can be used in other function
- user_name = raw_input("\"What is your name?\" roars the Bear. \n")
- print "Okay %s, let's play!\n" % user_name
- def number_check(guess_counter):
- print "The bear became infuriated, and chellenges you to a number guessing game for your life, you accept."
- user_guess=raw_input("Pick a number between 1 and 50 or be eaten! \n") # user input for guess
- user_guess=int(user_guess)
- while guess_counter <= 7:
- if 50 >= user_guess > random_number:
- print "Try again, the number you picked is too high. Guess %s of 8 the bear hints that he is funny\n %r." % (guess_counter, transaction_number) # number too high
- number_check(guess_counter+1)
- return
- elif 0 < user_guess < random_number:
- print "Try again, the number you picked is too low the bear is getting impatient. Guess %s of 8\n %r." % (guess_counter, transaction_number) # number too low
- number_check(guess_counter+1)
- return
- elif user_guess >= 51: # dodoesnt consume guess for invalid answer
- print "That's not an answer! The number is less than or equal to 50 the Bear scratches his head!\n %r" % transaction_number
- number_check(guess_counter)
- return
- elif user_guess <= 0: # "
- print "That's not an answer! The number is greater than or equal to 1 the Bear looks at you angrily!\n %r" % transaction_number
- number_check(guess_counter)
- return
- elif user_guess == random_number:
- print 'You Win %s! You got it in %s guesses!' % (user_name, guess_counter) # correct
- return
- else: # for the instance of running out of guesses
- if 50 >= user_guess > random_number:
- print "Guess 8 of 8, you lose, you were eaten by the Bear! The number you picked is too high, the correct number is %s. Play again sometime %s!" % (random_number,user_name,)
- elif 0 < user_guess < random_number:
- print "Guess 8 of 8, you lose, you were eaten by the Bear! The number you picked is too low, the correct number is %s. Play again sometime %s!" % (random_number,user_name,)
- elif user_guess == random_number:
- print "You Win %s! You got it in %s guesses!" % (user_name, guess_counter) # correct
- elif user_guess >= 51: # dodoesnt consume guess for invalid answer
- print "That's not an answer! The number is less than or equal to 50, the Bear growls at you!"
- number_check(guess_counter)
- return
- elif user_guess <= 0: # "
- print "That's not an answer! The number is greater than or equal to 1, the Bear is getting angry with you!" % transaction_number
- number_check(guess_counter)
- return
- name_input() # Calling function for user to input name
- number_check(1) # using 0 to have 8 guesses, to have less change number to be 8-inputted number = guesses
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement