-
-
Save stephengruppetta/a96d18fc81b6375518a1c1fd62956e08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
import random | |
def roll_dice(max_value, number_of_dice): | |
return [ | |
random.randint(1, max_value) | |
for _ in range(number_of_dice) | |
] | |
# Create a partial object that always rolls | |
# standard dice with 6 sides | |
roll_standard_dice = functools.partial(roll_dice, 6) | |
# Roll four standard dice | |
print(roll_standard_dice(4)) | |
# Roll two standard dice | |
print(roll_standard_dice(2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment