File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """The purpose of this program is to roll a quantity number of die type dice and provide the user with the results"""
2+ import random
3+
4+ die = input ("What die type (default is d6): " ) or "d6" #Promtps user for the type of die to roll or defaults to a six sided die
5+ quantity = input ("How many (default is 1): " ) or 1 #Prompts user for the number of dice to roll or defaults to 1
6+ quantity = int (quantity ) #Changes the user provided information (a string) into an integer for use in the range call in the for loop.
7+ total = 0 #Set total to 0
8+
9+ #There is probably a more eliegant way to do this but I don't know how
10+ if die == "d4" :
11+ sides = 4
12+ elif die == "d6" :
13+ sides = 6
14+ elif die == "d10" :
15+ sides = 10
16+ elif die == "d12" :
17+ sides = 12
18+ elif die == "d20" :
19+ sides = 20
20+ elif die == "d100" :
21+ sides = 100
22+ else :
23+ print ("That is not a die type" )
24+
25+ for i in range (0 , quantity ): #Iterates through the quantity of dice to be rolled and dieplays their individual results
26+ result = (random .randint (1 , sides ))
27+ print (i + 1 , die , " = " , result )
28+ total += result
29+ print ("This is the result of your roll: " , total )
You can’t perform that action at this time.
0 commit comments