Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 908 Bytes

File metadata and controls

48 lines (37 loc) · 908 Bytes
jupyter
jupytext kernelspec
formats text_representation
ipynb,md
extension format_name format_version jupytext_version
.md
markdown
1.3
1.19.1
display_name language name
Python 3 (ipykernel)
python
python3

Notebook to play games of chance!

import games
from matplotlib import pyplot as plt

The first game is flipping a coin. It will tell us either 'heads' or 'tails':

games.flip_a_coin()

Next up is rolling a die. Let's make sure it isn't biased by plotting a histogram of many rolls:

rolls = [games.roll_a_die(6) for i in range(1000)]
plt.hist(rolls, bins=[-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5])

Finally, we can pick a random card, which gives us two numbers that we can interpret as value and suit:

games.pick_a_card()
games.generate_ticket()