Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2 (10 Points) Game Show Problem Write a well-documented Python program, hmwk5Q2.py, to simulate a television game show. The contestant is given the option

image text in transcribed
Question 2 (10 Points) Game Show Problem Write a well-documented Python program, hmwk5Q2.py, to simulate a television game show. The contestant is given the option of selecting one of three boxes. One of the boxes has a prize. The other two boxes are empty. The odds of the contestant selecting are 1 in 3 or 33.3%. Once the contestant selects a box, the game show host reveals an empty box of the remaining two unselected boxes. The game show host allows the contestant to either keep their original selection or pick the remaining box, which was originally unselected. Estimate the probability of winning if the contestant ALWAYS changes their selection of the remaining box by running the experiment 100,000 times. Hints: Import the random module and use the function sample(range(3), 3) to simulate the placement of the gift within three boxes. Separately use the function sample(range(3), 1) to simulate the player's selection. Construct an if ladder for the case when the player picks 0, 1 or 2, using if, elif and else respectively. Inside each of the rungs of the if ladder place another if statement to switch the player's selection to the unselected box. Finally, after the else statement in the outer most if statement, define another if statement to determine if the player indeed wins the game and tallies the win accordingly. Record your estimate of the probability of the winning strategy as a comment within your program. Grading: Correct maino (42 points). Correct if ladder (+4 points). Correct if statements inside the if ladder (*2 points). Correct estimate for the winning probability using the strategy discussed (2 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions