''' Mission 8 - Answer Bot Medium Remix 2A Create a list of pictures, colors and text. Select a random item when button is pressed. This solution checks the type of item and correctly displays the choice. The second list is audio sounds already loaded on the CodeX (but could be anything). ''' from codex import * import random from time import sleep # My list of pictures, colors and text my_images = [pics.TIARA, GREEN, pics.PLANE, "hello!", pics.HAPPY, BLUE, pics.TARGET, "what's up?", RED, "Ahoy", pics.HEART] # my list of sounds my_sounds = ["sounds/up", "sounds/down", "sounds/one", "sounds/two", "sounds/three", "sounds/four", "sounds/yes", "sounds/no", "sounds/welcome", "sounds/button", "sounds/codex"] # Introduction display.print("A=images", scale=3) display.print("B=sounds", scale=3) display.print("D=quit", scale=3) while True: # Display random item when Button A is pressed if buttons.was_pressed(BTN_A): item = random.choice(my_images) if type(item) == tuple: display.fill(item) else: display.show(item) # Play audio sound when Button B is pressed if buttons.was_pressed(BTN_B): # Display instructions while playing sound display.clear() display.print("A=images", scale=3) display.print("B=sounds", scale=3) display.print("D=quit", scale=3) item = random.choice(my_sounds) audio.mp3(item) if buttons.was_pressed(BTN_D): break # Ending message display.clear() display.print("Thanks", scale=5)