Skip to content

Instantly share code, notes, and snippets.

@kageru
Last active January 17, 2018 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kageru/71824d28e784d648ff6d2557393a5e13 to your computer and use it in GitHub Desktop.
Save kageru/71824d28e784d648ff6d2557393a5e13 to your computer and use it in GitHub Desktop.
digital die, just paste in into the python/ipython shell
from random import randint
from functools import partial
def d(m, n=1):
s = 0
print(f'{n}d{m}')
for _ in range(n):
r = randint(1, m)
s += r
print(r)
if n > 1:
print('sum:', s)
d6 = partial(d, 6, 1)
d20 = partial(d, 20, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment