from machine import Pin
from utime import sleep
from random import randint

DICE_NO =(0x08, 0x41, 0x49, 0x55, 0x5D, 0x77)  # dice pattern
button = Pin(16, Pin.IN, Pin.PULL_UP)          # configure button as input
leds = [Pin(i, Pin.OUT) for i in range(1,8)]   # configures LEDs as outputs

def leds_output(p):
    for i in range(7):
        if p & (1 << i):
            leds[i].on()
        else:
            leds[i].off()

while True:
    if not button.value():               # Button pressed?
        pattern = DICE_NO[randint(0,5)]  # generate a random number, find the pattern
        print(DICE_NO.index(pattern)+1, end=" ")
        leds_output(pattern)             # turn ON required LEDs
        sleep(2)                         # wait for 2 seconds
        leds_output(0)                   # turn OFF all LEDs
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT