Monty Hall Problem
Monty Hall Problem – Coding Lab
In this lab, you will write a code that simulates the Monty Hall Game Show. The
game host gives the participant the choice of selecting one of three doors. Two
doors has a goat behind them and one door has a prize. The set of choices are
randomized each round. The participant needs to select the door with the prize
behind it. When the participant selects a door, the game host reveals a door with a
goat behind it. The game host opens a door (different from the one selected by the
participant) that has a goat behind it. The participant is then given the option to
change their choice.
When you run your code, the code would display a message prompting the user to
input their door choice, labelled as 1, 2, and 3. Then the code will display a door
number (different from the one the user picked) with a goat behind it and ask the
user if they would like to change their choice. The code then displays a message on
whether the user guessed the correct door. The game then restarts for another
round, displaying the first message that was shown at the beginning of code. The
game should run for a total of 5 rounds and at the end, the probability of the user
winning is displayed as the final message. The section of the program that runs the
game should be coded as a function.
You will need to learn how to use the input function as well as importing the
random package. random has different built in functions that generate randomized
values which will assist you in randomizing the choices for the doors. You will
need to include comments and briefly explain (at the end of your code) how you
would maximize your chances of winning. Would 5 rounds be enough to sample
the probability of winning or would you need to run the simulation several times?
How would you automate it if you need to run it several times?
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images