Advertisement
Guest User

Untitled

a guest
Dec 17th, 2014
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. import random
  2.  
  3. def main():
  4.  
  5.     dice_sides = 20
  6.     roll_count = 100
  7.  
  8.     rolls_col_width = len(str(dice_sides))
  9.     if rolls_col_width < 4:
  10.         rolls_col_width = 4
  11.    
  12.     rolls = [0] * dice_sides
  13.  
  14.     for i in range(roll_count):
  15.         rand = random.randint(1,dice_sides)
  16.         rolls[rand-1] += 1
  17.     #print(rolls)
  18.  
  19.     # Roll, Freq.
  20.     top = "╒" + "═"*rolls_col_width + "╤" + "═"*26 + "╕"
  21.     print(top)
  22.  
  23.     print("│Roll" + " "*(rolls_col_width-4) + "│Tally", end = "")
  24.     print(" "*21 + "│")
  25.  
  26.     print("╞" + "═"*rolls_col_width + "╪" + "═"*26 + "╡")
  27.  
  28.     for i in range(dice_sides):
  29.         tally_row = "●"*rolls[i]
  30.         empty = 26 - len(tally_row)
  31.        
  32.         print("│" + str(i+1) + " "*(rolls_col_width-len(str(i+1))) + "│" + tally_row + " "*empty + "│")
  33.  
  34.     print("╘" + "═"*rolls_col_width + "╧" + "═"*26 + "╛")
  35.  
  36. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement