''' Mission 8 Answer Bot Spicy Remix 3B Create a program that simulates a dice roll. This version uses a list for the possible values. ''' from codex import * from time import sleep import random dice_rolls = ["1", "2", "3", "4", "5", "6"] # Instructions display.print("Roll Dice", scale=3) display.print("Program", scale=3) display.print("Press U to start", scale=2) display.print("Press A to roll", scale=2) display.print("Press D to quit", scale=2) # Wait to start while True: if buttons.was_pressed(BTN_U): display.clear() break # Define variables - values don't change sides = 6 delay = 0.2 # Loop until break for repeated rolls while True: # if button is pressed, roll dice if buttons.was_pressed(BTN_A): display.clear() display.draw_text("Rolling", scale=3, x=35, y=80) sleep(delay*3) display.clear() # Display four random numbers, with the last one the final roll item = random.choice(dice_rolls) display.print(item, scale=20) sleep(delay) display.clear() item = random.choice(dice_rolls) display.print(item, scale=20) sleep(delay) display.clear() item = random.choice(dice_rolls) display.print(item, scale=20) sleep(delay) display.clear() item = random.choice(dice_rolls) display.print(item, scale=20) # Stop the rolling if buttons.was_pressed(BTN_D): break # Ending message display.clear() display.print("DONE", scale=5)