(mus be in Python) In the popular television game show of the 70s, Let\'s Make a
ID: 641473 • Letter: #
Question
(mus be in Python) In the popular television game show of the 70s, Let's Make a Deal, game show host, Monty Hall, would show a contestant 3 doors. Behind one of the doors was a prize and the contestant would have to guess which one it was. Once the contestant made a guess which door led to the prize, Monty Hall would open of the other doors showing that the prize was not behind it. The contestant then had the opportunity of changing his or her guess or sticking to the original guess. Monty Hall would then open the door that concealed the prize.
The common place belief was that there was no real advantage in changing one's guess. The reasoning went as follows: since one of the doors was eliminated, the prize would be behind one of the two remaining doors, i.e. the probability of if being behind the door the contestant guessed was 0.5. The probability of the prize being behind the other door was also 0.5. So the prize being behind one of the two doors was just as likely as being behind the other door. It did not make sense to switch.
In 1990, a reader of Parade magazine, wrote to Marilyn vos Savant asking her what the best strategy would be to play this game. Her advice was, that no matter what the initial guess was, to switch. You should read all the comments that other readers sent her including college professors berating her for her suggestion. But subsequent analysis has shown that she was right.
In this programming assignment you are going to simulate the game show and demonstrate that indeed Marilyn vos Savant gave sensible advice. The following describes the steps that you will be taking:
A sample session and output will look as follows:
Your program should have a good, clean logical structure. You must print out the results in the format specified. We will be looking at good documentation and descriptive variable names. Your file Deal.py will have the following header:
Explanation / Answer
import random
def main():
#prompt the user to enter input
count = int(input('Enter number of times you want to play: '))
#variables are initialized
prize, guess, view, newGuess, rightGuess = 0, 0, 0, 0, 0
print('Prize',' ','Guess',' ','View',' ','New Guess')
#loop to create random numbers between 1 and 3
for i in range(0, count):
prize = random.randint(1,3)
guess = random.randint(1,3)
#loop to create the number for View
for n in range(1,4):
if(n != prize and n!= guess):
view = n
#loop to create the number for New Guess
for m in range(1,4):
if(m != view and m!=guess):
newGuess = m
#tracking number of right guesses after switching
if(newGuess == prize):
rightGuess += 1
#printing the values
print(' ',prize,' ',guess,' ',view,' ',newGuess)
#results are printed out
print('Probability of winning if you switch = ', "%.2f" % round(rightGuess/count,2))
print('Probability of winning if you do not switch = ', "%.2f" % round((1-(rightGuess/count)),2))
main()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.