Question: Script Instructions . Create a script named monty_hall. This script should import random, and create a class named Simulation. Simulation should take an attribute, an

 Script Instructions . Create a script named monty_hall. This script should

Script Instructions . Create a script named monty_hall. This script should import random, and create a class named Simulation. Simulation should take an attribute, an integer, which represents the amount of doors that the simulation will use. When an instance of Simulation is created it should call the method set_doors using the number of doors. Set doors will use this number to create a list of "zonk" strings. This list should be as long as the number. Meaning, if the number passed in is 2, it should create a list containing two "zonks" ([ zonk","zonk"]). It should then replace one of those items in the list to the string "car" at random. It should then pick a random item from the list which represents the door that the user has chosen. It should then remove a "zonk" from the list (the order of the zonk doesn't matter for this part, it can be the first zonk, it can be the last zonk or it can be a random zonk). It should then pick a random door that the user has not chosen as the alternate door (similar to Deal or No Deal). o Simulation should contain a method named play_game which has 2 keyword arguments, switch (boolean, default value of False) and iterations (int, default value of 1). Iterations pertains to the amount of times that the game will be played in this Simulation instance. The goal of this method is to return the percentage of the amount of times that the game was won as a decimal (float). So for example, if my iterations is 3 (this means | play the game 3 times) and I win 2 of those 3 times, then my returned value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!