Advertisement
earlution

Magic 8-Ball

May 24th, 2023
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. # source: https://microbit-micropython.readthedocs.io/en/latest/tutorials/gestures.html#magic-8
  2.  
  3. from microbit import *
  4. import random
  5.  
  6. answers = [
  7.     "It is certain",
  8.     "It is decidedly so",
  9.     "Without a doubt",
  10.     "Yes, definitely",
  11.     "You may rely on it",
  12.     "As I see it, yes",
  13.     "Most likely",
  14.     "Outlook good",
  15.     "Yes",
  16.     "Signs point to yes",
  17.     "Reply hazy try again",
  18.     "Ask again later",
  19.     "Better not tell you now",
  20.     "Cannot predict now",
  21.     "Concentrate and ask again",
  22.     "Don't count on it",
  23.     "My reply is no",
  24.     "My sources say no",
  25.     "Outlook not so good",
  26.     "Very doubtful",
  27. ]
  28.  
  29. while True:
  30.     display.show("8")
  31.     if accelerometer.was_gesture("shake"):
  32.         display.clear()
  33.         sleep(1000)
  34.         display.scroll(random.choice(answers))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement