Write a function called
simulate_several_key_strikes
. It should take one ar-
gument: an integer specifying the number of key strikes to simulate. It should return a string
containing that many characters, each one obtained from simulating a key strike by the monkey.
Hint:
If you make a list or array of the simulated key strikes, you can convert that to a string
by calling
"".join(key_strikes_array)
(if your array is called
key_strikes_array
).

5

---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed
Question 4.
Use
simulate_several_key_strikes
1000 times, each time simulating the mon-
key striking 11 keys. Compute the proportion of times the monkey types
"datascience"
, calling
that proportion
datascience_proportion
.

Question 5.
Check the value your simulation computed for
datascience_proportion
. Is your
simulation a good way to estimate the chance that the monkey types
"datascience"
in 11 strikes
(the answer to question 1)? Why or why not?

Question 6.
Compute the chance that the monkey types the letter
"e"
at least once in the 11
strikes. Call it
e_chance
. Use algebra and type in an arithmetic equation that Python can evalute.

6

Out[19]:
0.35041906843673165
In [20]:
_
=
ok
.
grade(
'
q2_6
'
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running tests
---------------------------------------------------------------------
Test summary
Passed: 1
Failed: 0
[ooooooooook] 100.0% passed
Question 7.
In comparison to
datascience_chance
, do you think that a computer simulation
would be a more or less effective way to estimate
e_chance
? Why or why not? (You don’t need to
write a simulation, but it is an interesting exercise.)