''' Mission 8 Answer Bot Medium Remix 2B Create a list of pictures, colors and text. Create a second list of JPG pictures. Select a random item when button is pressed. This solution checks the type of item and correctly displays the choice. It also uses JPGs loaded onto the CodeX, so you will not see the pictures if you run the code. You will need to upload and use your own pictures for a demonstration. ''' 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 JPG pics uploaded to Codex my_pics = ["pics/doggie.jpg", "pics/goldfish.jpg", "pics/kitty.jpg", "pics/piggie.jpg", "pics/rabbits2.jpg", "pics/tortoise.jpg", "pics/my_loves.jpg", "pics/sunDevil.jpg", "pics/firia.jpg", "pics/kyoto.jpg", "pics/christmas.jpg"] # Introduction display.print("A=images", scale=3) display.print("B=pictures", 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) # Display random picture when Button B is pressed if buttons.was_pressed(BTN_B): item = random.choice(my_pics) display.draw_jpg(item) if buttons.was_pressed(BTN_D): break # Ending message display.clear() display.print("Thanks", scale=5)