Advertisement
SaxTiger

Programming Trouble V2

Oct 31st, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. """This is a program that will calculate your odds of winning a game if you
  2. choose between 3 doors and then change again after your first guess"""
  3.  
  4. """Think of this as the game show the price is right, 3 doors are presented
  5. and you pick a first door,this door can be correct or not.
  6. The show host (who knows the right door) will then open up one of the two
  7. other doors that isnt your guess, obviously one that does not have the prize behind it.
  8. you are then given the option to keep your door or to choose the other
  9. open door."""
  10.  
  11.  
  12. import random
  13.  
  14. Doors = ['door1', 'door2', 'door3']
  15. print(Doors)
  16. door1 = 1
  17. door2 = 2
  18. door3 = 3
  19. games = 0
  20. Wins = 0
  21.  
  22. while games < 1000:
  23. Doors = [door1, door2, door3]
  24.  
  25. WinningDoor = random.randrange(1,4)
  26.  
  27. RandomGuess = random.randrange(1,4)
  28. RandomGuess2 = RandomGuess
  29.  
  30.  
  31. #this if statement is set up for if neither the winning door or random guess
  32. #are equal to 1. 1 will be the door that is "opened" by the "gameshow host"
  33.  
  34. if WinningDoor != 1 and RandomGuess != 1:
  35. Doors[:1] = []
  36. while RandomGuess2 == RandomGuess:
  37. RandomGuess = random.randrange(2, 4)
  38.  
  39.  
  40. #this if statement is set up for if neither the winning door or random guess
  41. #are equal to 2. 2 will be the door that is "opened" by the "gameshow host"
  42.  
  43. elif WinningDoor != 2 and RandomGuess != 2:
  44. Doors.pop(1)
  45. while RandomGuess2 == RandomGuess:
  46. RandomGuess = random.randrange(1,4)
  47. print("infinite loop")
  48.  
  49.  
  50. #this if statement is set up for if neither the winning door or random guess
  51. #are equal to 3. 3 will be the door that is "opened" by the "gameshow host"
  52.  
  53. elif WinningDoor != 3 and RandomGuess != 3:
  54. Doors.pop(2)
  55. while RandomGuess2 == RandomGuess:
  56. RandomGuess = random.randrange(1,3)
  57.  
  58.  
  59. if WinningDoor == RandomGuess:
  60. Wins = Wins + 1
  61.  
  62. games = games + 1
  63.  
  64. print(Wins)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement