Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def main():
- dice_sides = 20
- roll_count = 100
- rolls_col_width = len(str(dice_sides))
- if rolls_col_width < 4:
- rolls_col_width = 4
- rolls = [0] * dice_sides
- for i in range(roll_count):
- rand = random.randint(1,dice_sides)
- rolls[rand-1] += 1
- #print(rolls)
- # Roll, Freq.
- top = "╒" + "═"*rolls_col_width + "╤" + "═"*26 + "╕"
- print(top)
- print("│Roll" + " "*(rolls_col_width-4) + "│Tally", end = "")
- print(" "*21 + "│")
- print("╞" + "═"*rolls_col_width + "╪" + "═"*26 + "╡")
- for i in range(dice_sides):
- tally_row = "●"*rolls[i]
- empty = 26 - len(tally_row)
- print("│" + str(i+1) + " "*(rolls_col_width-len(str(i+1))) + "│" + tally_row + " "*empty + "│")
- print("╘" + "═"*rolls_col_width + "╧" + "═"*26 + "╛")
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement