In this project we will recreate the magic 8 ball toy using turtle graphics in Python. You may find slides 151 - 178 of this slide presentation helpful.
Have fun and be creative. Your magic 8 ball app doesn't have to work or look like anyone else's. (Students in the past have used different artwork to create apps like "Ask the magic olive", "Ask Al Gore" or "Ask Bootsy Collins.")
The original Magic 8 Ball toy had 20 answers. You can use these answers or create your own:
- It is certain
- It is decidedly so
- Without a doubt
- Yes definitely
- You may rely on it
- As I see it, yes
- Most likely
- Outlook good
- Yes
- Signs point to yes
- Reply hazy try again
- Ask again later
- Better not tell you now
- Cannot predict now
- Concentrate and ask again
- Don't count on it
- My reply is no
- My sources say no
- Outlook not so good
- Very doubtful
For full credit, your finished program should
- Provide an answer based on user input (e.g. clicking the mouse or typing on the keyboard)
- Store the answers in a list
- Use one of Python's
random
functions to choose one answer randomly from the list and display it - Define at least one function (e.g. a function that uses Python's turtle graphics to display a suituable picture)
- You will need two
import
statements at the top of the program
import turtle
from random import *
- Define a function using the Python keyword
def
that draws your 8 ball or other design. - Call the function after its definition
- Ask the user to enter their questions using the
textinput
function and store the question in a variable - Create a list of answers, for example,
answers = ["yes","no","maybe"]
- Display a random answer useing the the
write()
andrandint()
function (see slides 150-152 for examples) - Write a
while
loop that continues to allow the user to ask questions until they indicate that they are done - You may find the
turtle.clearscreen()
function helpful in erasing the previous answer