SHARE
TWEET

Untitled

a guest Feb 16th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def ChooseGame():
  2.     x=input('What do you want to play? Guess the Number or Cave Treasure\n')
  3.     if x=='GuessNumber':
  4.         playGuessNumber()
  5.     if x=='CaveTreasure':
  6.         playCaveTreasure()
  7.    
  8. #####################################
  9.    
  10. def GuessNumber():
  11.     import random
  12.  
  13. GuessesTaken = 0
  14.  
  15. print('Hello! What is your name?')
  16. myName = input()
  17.  
  18. number = random.randint(1, 20)
  19. print ('Well, ' + myName + ', I am thinking of a number between 1 and 20.')
  20.  
  21. for guessesTaken in range(6):
  22.     print('Take a guess.') # Four spaces in front of "print"
  23.     guess = input()
  24.     guess = int(guess)
  25.  
  26.     if guess < number:
  27.         print('Your guess is too low.') # Eight spaces in front of "print"
  28.  
  29.     if guess > number:
  30.         print('Your guess is too high.')
  31.  
  32.     if guess == number:
  33.         break
  34.  
  35. if guess == number:
  36.     guessesTaken = str(guessesTaken + 1)
  37.     print('Good job, ' + myName + '! You guessed my number in ' + guessesTaken + ' guesses!')
  38.  
  39. if guess != number:
  40.         number = str(number)
  41.         print ('Nope. The number I was thinking of was ' + number + '.')
  42. ##########################################################################
  43.        
  44. def CaveTreasure():
  45.     import random
  46. import time
  47.  
  48. def displayIntro():
  49.     print('''You are in a land full of dragons. In front of you,
  50. you see two caves. In one cave, the dragon is friendly
  51. and will share his treasure with you. The other dragon
  52. is greedy and hungry, and will eat you on sight.''')
  53. print()
  54.  
  55. def chooseCave():
  56.     cave = ''
  57.     while cave != '1' and cave != '2':
  58.         print('Which cave will you go into? (1 or 2)')
  59.         cave = input()
  60.  
  61.     return cave
  62.  
  63. def checkCave(chosenCave):
  64.     print('You approach the cave...')
  65.     time.sleep(2)
  66.     print('It is dark and spooky...')
  67.     time.sleep(2)
  68.     print('A large dragon jumps out in front of you! He opens his jaws and...')
  69.     print()
  70.     time.sleep(2)
  71.  
  72.     friendlyCave = random.randint(1,2)
  73.  
  74.     if chosenCave == str(friendlyCave):
  75.         print('Gives you his treasure!')
  76.     else:
  77.         print('Gobbles you down in one bite!')
  78.  
  79. playAgain = 'yes'
  80. while playAgain == 'yes' or playAgain == 'y':
  81.     displayIntro()
  82.     caveNumber = chooseCave()
  83.     checkCave(caveNumber)
  84.  
  85.     print('Do you want to play again? (yes or no)')
  86.     playAgain=input()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top