Problem 0 (0pts)
The dice.py
file represents dice using non-pure zero-argument functions.
These functions are non-pure because they may have different return values each time they are called.
The documentation of dice.py
describes the two different types of dice used in the project:
- A fair dice produces each possible outcome with equal probability.
Two fair dice are already defined,
four_sided
andsix_sided
, and are generated by themake_fair_dice
function. - A test dice is deterministic: it always cycles through a fixed sequence of values that are passed as arguments.
Test dice are generated by the
make_test_dice
function.
Before writing any code, read over the dice.py
file and check your understanding by unlocking the following tests.
$ python ok -q 00 -u
This should display a prompt that looks like this:
=====================================================================
Assignment: proj01: Hog
Ok, version vx.y.z
=====================================================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unlocking tests
At each "? ", type what you would expect the output to be.
Type exit() to quit
---------------------------------------------------------------------
Question 0 > Suite 1 > Case 1
(cases remaining: 1)
>>> test_dice = make_test_dice(4, 1, 2)
>>> test_dice()
?
You should type in what you expect the output to be.
To do so, you need to first figure out what test_dice
will do, based on the description above.
You can exit the unlocker by typing exit()
.
Typing
Ctrl-C
on Windows to exit out of the unlocker has been known to cause problems, so avoid doing so.
In general, for each of the unlocking tests, you might find it helpful to read through the provided skeleton for that problem before attempting the unlocking test.