Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
29 lines (26 loc) · 1.08 KB

File metadata and controls

executable file
·
29 lines (26 loc) · 1.08 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""The purpose of this program is to roll a quantity number of die type dice and provide the user with the results"""
import random
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
quantity = input("How many (default is 1): ") or 1 #Prompts user for the number of dice to roll or defaults to 1
quantity = int(quantity) #Changes the user provided information (a string) into an integer for use in the range call in the for loop.
total = 0 #Set total to 0
#There is probably a more eliegant way to do this but I don't know how
if die == "d4":
sides = 4
elif die == "d6":
sides = 6
elif die == "d10":
sides = 10
elif die == "d12":
sides = 12
elif die == "d20":
sides = 20
elif die == "d100":
sides = 100
else:
print("That is not a die type")
for i in range(0, quantity): #Iterates through the quantity of dice to be rolled and dieplays their individual results
result = (random.randint(1, sides))
print(i+1, die, " = ", result)
total += result
print("This is the result of your roll: ", total)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.