Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started