Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.10 KB | None | 0 0
  1. # File: lotterySimulation.py
  2. # WWU Computer Science
  3. # CSCI 141
  4.  
  5. # import the random module
  6. import random
  7.  
  8. # Generate the "winning" pick, which is
  9. # a word and the digit 1, 2 or 3. The word
  10. # or digit can be first
  11. def generateWinningPick():
  12.  
  13.     # generate the random integer 1, 2 or 3
  14.     aRandomInteger = random.randrange(1,4)
  15.  
  16.     # Select one of three words, and return
  17.     # the winning pick, which is a concatenation
  18.     # of the word and the str equivalent
  19.     # of aRandomInteger
  20.     anotherRandomNum = random.randrange(1,6)
  21.     if (anotherRandomNum == 1):
  22.         return "monkey" + str(aRandomInteger)
  23.     elif (anotherRandomNum == 2):
  24.         return "dragon" + str(aRandomInteger)
  25.     elif (anotherRandomNum == 3):
  26.         return "snake" + str(aRandomInteger)
  27.     elif (anotherRandomNum == 4):
  28.         return str(aRandomInteger) + "dragon"
  29.     elif (anotherRandomNum == 5):
  30.         return str(aRandomInteger) + "monkey"
  31.    
  32.     else:
  33.         return str(aRandomInteger) + "snake"
  34.  
  35. # the main function
  36. def main():
  37.  
  38.     # generate the winning lottery pick
  39.     winningPick = generateWinningPick()
  40.  
  41.     # print welcome message
  42.     print("Lottery pic checker V1.2. Let's see if you've won")
  43.     print("a favulous prize. The word choices were monkey,")
  44.     print("dragon, and snake, and digit choices were 1, 2 or 3.")
  45.     print("The winning pick is a word and digit, in any order.")
  46.    
  47. #DELETE THISSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
  48.     print(winningPick)
  49.    
  50.     numberInput = False
  51.     wordInput = False
  52.     while (numberInput == False or wordInput == False):
  53.         numberInput = False
  54.         wordInput = False
  55.         userGuess = input("What word/combination did you select? ")
  56.         for aNum in("1" , "2" , "3"):
  57.             if(aNum in userGuess):
  58.                 numberInput = True
  59.         for aWord in ("dragon" , "monkey" , "snake"):
  60.             if (aWord in userGuess):
  61.                 wordInput = True
  62.         if(numberInput == False):
  63.             print("Please try again. And this time, input a valid number! (1, 2, or 3)")
  64.         if(wordInput == False):
  65.             print("Please try again. And this time, input a valid word! (monkey, dragon, or snake")
  66.     numEntered = ""
  67.     wordEntered = ""
  68.     for x in ("1" , "2" , "3"):
  69.         if (userGuess[0] == x):
  70.             numEntered = userGuess[0]
  71.             wordEntered = userGuess[1:]
  72.         if(userGuess[-1] == x):
  73.             numEntered = userGuess[-1]
  74.             wordEntered = userGuess[:-1]
  75.     if(userGuess == winningPick):
  76.         print("You win the big bucks! Woo hoo!")
  77.     elif(numEntered in winningPick and wordEntered in winningPick):
  78.         print("You guessed the right word and number...but in the wrong order!")
  79.     elif(numEntered in winningPick and wordEntered not in winningPick):
  80.         print("You guessed the right number but the wrong word!")
  81.     elif(wordEntered in winningPick and numEntered not in winningPick):
  82.         ("You guessed the right word but the wrong number!")
  83.     else:
  84.         print("You guessed neither the word, nor the number.")
  85.    
  86. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement