Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """This is a program that will calculate your odds of winning a game if you
- choose between 3 doors and then change again after your first guess"""
- """Think of this as the game show the price is right, 3 doors are presented
- and you pick a first door,this door can be correct or not.
- The show host (who knows the right door) will then open up one of the two
- other doors that isnt your guess, obviously one that does not have the prize behind it.
- you are then given the option to keep your door or to choose the other
- open door."""
- import random
- Doors = ['door1', 'door2', 'door3']
- print(Doors)
- door1 = 1
- door2 = 2
- door3 = 3
- games = 0
- Wins = 0
- while games < 1000:
- Doors = [door1, door2, door3]
- WinningDoor = random.randrange(1,4)
- RandomGuess = random.randrange(1,4)
- RandomGuess2 = RandomGuess
- #this if statement is set up for if neither the winning door or random guess
- #are equal to 1. 1 will be the door that is "opened" by the "gameshow host"
- if WinningDoor != 1 and RandomGuess != 1:
- Doors[:1] = []
- while RandomGuess2 == RandomGuess:
- RandomGuess = random.randrange(2, 4)
- #this if statement is set up for if neither the winning door or random guess
- #are equal to 2. 2 will be the door that is "opened" by the "gameshow host"
- elif WinningDoor != 2 and RandomGuess != 2:
- Doors.pop(1)
- while RandomGuess2 == RandomGuess:
- RandomGuess = random.randrange(1,4)
- print("infinite loop")
- #this if statement is set up for if neither the winning door or random guess
- #are equal to 3. 3 will be the door that is "opened" by the "gameshow host"
- elif WinningDoor != 3 and RandomGuess != 3:
- Doors.pop(2)
- while RandomGuess2 == RandomGuess:
- RandomGuess = random.randrange(1,3)
- if WinningDoor == RandomGuess:
- Wins = Wins + 1
- games = games + 1
- print(Wins)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement