forked from souravjain540/Basic-Python-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdice_roller.py
More file actions
21 lines (16 loc) · 677 Bytes
/
dice_roller.py
File metadata and controls
21 lines (16 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from random import randint, seed
# The randint(a,b) function return a pseudorandom number between a and b, including both.
# The seed() function defines a new seed for pseudorandom numbers.
# This function defines a die roll. If no specific side is defined, it 'rolls' a six-sided die.
def die(sides=6):
seed()
result = randint(1, sides)
return result
# This function defines a dice roll.
# If no specific side and number of dies are defined, it 'rolls' a six-sided die.
#Returns a list of ints with the dice rolls.
def dice(number_of_die=1, sides=6):
rolls = []
for roll in range(0, number_of_die):
rolls.append(die(sides))
return rolls