Advertisement
okelikai

Bear Update Project

May 18th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. import random
  2. def bear_game():
  3. print "You enter a dark room with two doors. Do you go through door #1 or door #2?"
  4.  
  5. door = raw_input("> ")
  6.  
  7. if door == "1":
  8. print "There's a giant bear here eating a cheese cake. What do you do?"
  9. print "1. Take the cake."
  10. print "2. Scream at the bear."
  11.  
  12. bear = raw_input("> ")
  13.  
  14. if bear == "1":
  15. random_number_game()
  16. elif bear == "2":
  17. random_number_game()
  18. else:
  19. print "Well, doing %s is probably better. Bear runs away." % bear
  20.  
  21. elif door == "2":
  22. print "You stare into the endless abyss at Cthulhu's retina."
  23. print "1. Blueberries."
  24. print "2. Yellow jacket clothespins."
  25. print "3. Understanding revolvers yelling melodies."
  26.  
  27. insanity = raw_input("> ")
  28.  
  29. if insanity == "1" or insanity == "2":
  30. print "Your body survives powered by a mind of jello. Good job!"
  31. else:
  32. print "The insanity rots your eyes into a pool of muck. Good job!"
  33.  
  34. else:
  35. print "You stumble around and fall on a knife and die. Good job!"
  36. bear_game()
  37.  
  38. def transaction_number_generator():
  39. global transaction_number # can be acessed in other
  40. sequence_letter_one = random.choice(['a','b','c','d','e','f','g'])
  41. sequence_letter_two = random.choice(['a','b','c','d','e','f','g'])
  42. sequence_letter_three = random.choice(['a','b','c','d','e','f','g'])
  43. sequence_number_one = random.choice(['1','2','3','4','5','6','7','8','9','0'])
  44. sequence_number_two = random.choice(['1','2','3','4','5','6','7','8','9','0'])
  45. transaction_number = "%s%s%s%s%s" % (sequence_letter_one,sequence_letter_two,sequence_number_one,sequence_letter_three,sequence_number_two)
  46. transaction_number_generator()
  47. def random_number_game():
  48. import random # import random
  49. global random_number
  50. random_number = random.choice(range(1, 51)) # Generating random number
  51.  
  52. def name_input():
  53. global user_name # so name can be used in other function
  54. user_name = raw_input("\"What is your name?\" roars the Bear. \n")
  55. print "Okay %s, let's play!\n" % user_name
  56.  
  57. def number_check(guess_counter):
  58. print "The bear became infuriated, and chellenges you to a number guessing game for your life, you accept."
  59. user_guess=raw_input("Pick a number between 1 and 50 or be eaten! \n") # user input for guess
  60. user_guess=int(user_guess)
  61. while guess_counter <= 7:
  62. if 50 >= user_guess > random_number:
  63. 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
  64. number_check(guess_counter+1)
  65. return
  66. elif 0 < user_guess < random_number:
  67. 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
  68. number_check(guess_counter+1)
  69. return
  70. elif user_guess >= 51: # dodoesnt consume guess for invalid answer
  71. print "That's not an answer! The number is less than or equal to 50 the Bear scratches his head!\n %r" % transaction_number
  72. number_check(guess_counter)
  73. return
  74. elif user_guess <= 0: # "
  75. 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
  76. number_check(guess_counter)
  77. return
  78. elif user_guess == random_number:
  79. print 'You Win %s! You got it in %s guesses!' % (user_name, guess_counter) # correct
  80. return
  81. else: # for the instance of running out of guesses
  82. if 50 >= user_guess > random_number:
  83. 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,)
  84. elif 0 < user_guess < random_number:
  85. 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,)
  86. elif user_guess == random_number:
  87. print "You Win %s! You got it in %s guesses!" % (user_name, guess_counter) # correct
  88. elif user_guess >= 51: # dodoesnt consume guess for invalid answer
  89. print "That's not an answer! The number is less than or equal to 50, the Bear growls at you!"
  90. number_check(guess_counter)
  91. return
  92. elif user_guess <= 0: # "
  93. print "That's not an answer! The number is greater than or equal to 1, the Bear is getting angry with you!" % transaction_number
  94. number_check(guess_counter)
  95. return
  96. name_input() # Calling function for user to input name
  97. 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