Advertisement
here2share

# b_barchart.py

Aug 12th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. # b_barchart.py
  2.  
  3. ch=chr(219)
  4. def col(sz):
  5.     mn,mx=min(sz),max(sz)
  6.     df = (mx-mn)//8
  7.     bkt = [(el-mn)//df for el in sz]
  8.     hrz = [b+c for b,c in [(ch*(el+1)," "*(8-el))  for el in bkt]]
  9.     return "\n".join([" ".join(el) for el in list(map(list, zip(*hrz)))[::-1]])
  10.    
  11. import random
  12.  
  13. for z in 'zz':
  14.     print
  15.     series = [random.randint(10, 99) for _ in range(25)]
  16.     print(col(series))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement