Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions