Advertisement
alynna

microbit randbits

Aug 19th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. from microbit import *
  2. import random
  3.  
  4. X = bytearray(256)
  5.  
  6. while True:
  7.     if not random.getrandbits(8): random.seed()
  8.     Y = random.getrandbits(8)
  9.     X[Y]+=1
  10.     display.clear()
  11.     display.set_pixel(int((Y % 52) / 11),int(Y / 52), 9)
  12.     print("{0:3} {1:65s} {2:3}".format(Y, "*" * int(X[Y]/4), X[Y]))
  13.     #print()
  14.     sleep(10)
  15.     if button_a.is_pressed() or X[Y]==255: break
  16.    
  17. for j in range(0,256):
  18.     print("{0:3} {1:65s} {2:3}".format(j, "*" * int(X[j]/4), X[j]))
  19.     sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement