Question
python programming you should use While loop For loop Range() Break Continue Here is a quick story about two elephants who live in the Potowatomi
python programming
you should use
- While loop
- For loop
- Range()
- Break
- Continue
Here is a quick story about two elephants who live in the Potowatomi Zoo. Every evening the elephants each randomly select one of six sleeping pens to spend the night in. After deciding on which pen, they simultaneously enter the pen from opposite sides. Being slightly vision impaired, they cannot see if the other elephant entered the same pen until it is too late to turn around and go to another pen to spend the night. Thus sometimes they must each spend an uncomfortable night sharing a small sleeping area with another elephant.
After the elephants are asleep the zookeeper randomly picks one of the pens to check. During a break, the zookeeper and the nighttime custodian were talking. The zookeeper told the custodian that 1/3rd of the time when he checks a pen, there's at least one elephant in there, and of the times that there's at least one elephant in the pen, 1/6th of the time the other elephant is in there as well. The custodian said that those percentages cannot be correct, but the zookeeper insisted they are.
Your job is to write a program to simulate this nightly activity 100,000 times to determine if the zookeeper or the custodian is correct. As a simulation, you will program all steps of this process. You are not writing a statistical analysis program to calculate probabilities.
You will report the following statistics.
- What percentage of the time there is at least one elephant in the pen the zookeeper checks?
- When there is an elephant in the pen the zookeeper checks, what percentage of time are both elephants in the pen?
- Based on the results of your simulation, is the zookeeper or the custodian correct? (Use 2% points as the margin of error)
Your results should be displayed as percentages with two decimal places.
After your results are displayed, you will prompt the user to choose to end the program or run the simulation again. That way, whomever the results indicate is wrong, can easily try another simulation to see if the results were a fluke. You can use a simple message such as:
Run the simulation again? (yes or no):
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