Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Im trying to program a magic 8 ball where i can ask a question and itll randomly give me 1 of 20 different answers. i

Im trying to program a magic 8 ball where i can ask a question and itll randomly give me 1 of 20 different answers.

i have to use turtle to draw out the 8 ball as well and have it display the answers in the middle, I'm not real good with python just tinkering and the basics so help would be much appreciated!

I've already got the turtle measurements and the questions written out, but i just have no idea how to put it all together!

heres the code:

def main():

#create 8 ball with turtle

turtle.hideturtle() turtle.penup() turtle.goto(0,-160) turtle.pendown() turtle.fillcolor("black") turtle.begin_fill() turtle.circle(200) turtle.end_fill() turtle.penup() turtle.goto(0,-110) turtle.pendown() turtle.fillcolor("dark purple") turtle.begin_fill() turtle.circle(150) turtle.end_fill() turtle.penup() turtle.goto(0,95) turtle.fillcolor("light grey") turtle.pendown() turtle.begin_fill() turtle.goto(0,95) turtle.goto(120,95) turtle.goto(0,-100) turtle.goto(-120,95) turtle.goto(0,95) turtle.end_fill() inputFunction() questions() #import modules import sys import random ans1=True while ans1: que=input("Ask the magic 8 ball a question: ") print(" ") anss=random.randint(1,20) if que== ".": sys.exit() elif anss== 1: print("It is certain") elif anss== 2: print("It is decidedly so") elif anss== 3: print("Without a doubt") elif anss== 4: print("Yes - definitely") elif anss==5: print("You may rely on it") elif anss== 6: print("As i see it, yes") elif anss== 7: print("Most likely") elif anss== 8: print("Outlock is good") elif anss== 9: print("Yes") elif anss== 10: print("Signs point to yes")

elif anss== 11: print("Reply hazy, try again")

elif anss== 12: print("Ask again later") elif anss== 13: print("Better not tell you now") elif anss== 14: print("Cannot predict now")

elif anss== 15: print("Concentrate and ask again")

elif anss== 16: print("Don't count on it")

elif anss== 17: print("My reply is no")

elif anss== 18: print("My sources say no")

elif anss== 19: print("Outlook is no good")

elif anss== 20: print("very doubtful")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago