We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9629aef commit 48f2a9eCopy full SHA for 48f2a9e
dice_roller.py
@@ -0,0 +1,21 @@
1
+from random import randint, seed
2
+
3
+# The randint(a,b) function return a pseudorandom number between a and b, including both.
4
+# The seed() function defines a new seed for pseudorandom numbers.
5
6
+# This function defines a die roll. If no specific side is defined, it 'rolls' a six-sided die.
7
8
+def die(sides=6):
9
+ seed()
10
+ result = randint(1, sides)
11
+ return result
12
13
+# This function defines a dice roll.
14
+# If no specific side and number of dies are defined, it 'rolls' a six-sided die.
15
+#Returns a list of ints with the dice rolls.
16
17
+def dice(number_of_die=1, sides=6):
18
+ rolls = []
19
+ for roll in range(0, number_of_die):
20
+ rolls.append(die(sides))
21
+ return rolls
0 commit comments