Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 4 (2 points) Now, let's bring the pieces together and simulate a game. In this exercise, you will complete the given simulate game function

image text in transcribedimage text in transcribedimage text in transcribed

Exercise 4 (2 points) Now, let's bring the pieces together and simulate a game. In this exercise, you will complete the given simulate game function that simulates Monty Hall game 10000 times. The function has 2 input arguments: . n: Number of doors k: Number of doors to be opened be Monty decision: Either Stay or Switch The function returns the number of wins for that particular decision num won: An integer count of the number of wins resulting from the decision . Hint: You have to think about how you will use the following functions - first_choice, initialize_game final_decision and monty_opens and what their input parameters should be to complete the exercise. In def simulate_game (n, k, decision): num won = 0 #variable to keep a track of the number of times the player won assert decision-- 'Switch' or decision "Stay"Check the parameter input for decision for i in range(10000) # YOUR CODE HERE return (num won) In [ ]: #### Test code #Case 1 num won - simulate_game (3,1, 'switch') prob_switch_won num_won/10000 assert prob_switch won

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Advances In Databases 28th British National Conference On Databases Bncod 28 Manchester Uk July 2011 Revised Selected Papers Lncs 7051

Authors: Alvaro A.A. Fernandes ,Alasdair J.G. Gray ,Khalid Belhajjame

2011th Edition

3642245765, 978-3642245763

More Books

Students also viewed these Databases questions