Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # File: lotterySimulation.py
- # WWU Computer Science
- # CSCI 141
- # import the random module
- import random
- # Generate the "winning" pick, which is
- # a word and the digit 1, 2 or 3. The word
- # or digit can be first
- def generateWinningPick():
- # generate the random integer 1, 2 or 3
- aRandomInteger = random.randrange(1,4)
- # Select one of three words, and return
- # the winning pick, which is a concatenation
- # of the word and the str equivalent
- # of aRandomInteger
- anotherRandomNum = random.randrange(1,6)
- if (anotherRandomNum == 1):
- return "monkey" + str(aRandomInteger)
- elif (anotherRandomNum == 2):
- return "dragon" + str(aRandomInteger)
- elif (anotherRandomNum == 3):
- return "snake" + str(aRandomInteger)
- elif (anotherRandomNum == 4):
- return str(aRandomInteger) + "dragon"
- elif (anotherRandomNum == 5):
- return str(aRandomInteger) + "monkey"
- else:
- return str(aRandomInteger) + "snake"
- # the main function
- def main():
- # generate the winning lottery pick
- winningPick = generateWinningPick()
- # print welcome message
- print("Lottery pic checker V1.2. Let's see if you've won")
- print("a favulous prize. The word choices were monkey,")
- print("dragon, and snake, and digit choices were 1, 2 or 3.")
- print("The winning pick is a word and digit, in any order.")
- #DELETE THISSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
- print(winningPick)
- numberInput = False
- wordInput = False
- while (numberInput == False or wordInput == False):
- numberInput = False
- wordInput = False
- userGuess = input("What word/combination did you select? ")
- for aNum in("1" , "2" , "3"):
- if(aNum in userGuess):
- numberInput = True
- for aWord in ("dragon" , "monkey" , "snake"):
- if (aWord in userGuess):
- wordInput = True
- if(numberInput == False):
- print("Please try again. And this time, input a valid number! (1, 2, or 3)")
- if(wordInput == False):
- print("Please try again. And this time, input a valid word! (monkey, dragon, or snake")
- numEntered = ""
- wordEntered = ""
- for x in ("1" , "2" , "3"):
- if (userGuess[0] == x):
- numEntered = userGuess[0]
- wordEntered = userGuess[1:]
- if(userGuess[-1] == x):
- numEntered = userGuess[-1]
- wordEntered = userGuess[:-1]
- if(userGuess == winningPick):
- print("You win the big bucks! Woo hoo!")
- elif(numEntered in winningPick and wordEntered in winningPick):
- print("You guessed the right word and number...but in the wrong order!")
- elif(numEntered in winningPick and wordEntered not in winningPick):
- print("You guessed the right number but the wrong word!")
- elif(wordEntered in winningPick and numEntered not in winningPick):
- ("You guessed the right word but the wrong number!")
- else:
- print("You guessed neither the word, nor the number.")
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement