0% found this document useful (0 votes)
29 views1 page

8 Ball Game

The document describes a magic 8 ball game that allows the user to ask a question and receives a random response. The program imports random, defines potential answers, gets user input, randomly selects an answer using randint(), and prints the response.

Uploaded by

k565
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

8 Ball Game

The document describes a magic 8 ball game that allows the user to ask a question and receives a random response. The program imports random, defines potential answers, gets user input, randomly selects an answer using randint(), and prints the response.

Uploaded by

k565
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

# MY MAGIC A BALL

import random

# write answers
ans1="good luck"
ans2="go home"
ans3="ask someone else"
ans4="better luck next time"
ans5="that’s sad"
ans6="good for you"
ans7="aww"
ans8="hahaha"

print("Welcome to MyMagicBallGame.")

# get the user's question


qustion = input("Ask me for advice then press ENTER to shake me.\n")

print("shaking ...\n" * 4)
# use the randint() function to select the correct answer
choice=[Link](1, 8)
if choice==1:
answer=ans1
elif choice==2:
answer=ans2
elif choice==3:
answer=ans3
elif choice==4:
answer=ans4
elif choice==5:
answer=ans5
elif choice==6:
answer=ans6
elif choice==7:
answer=ans7
else:
answer=ans8

# printthe answer to the screen


print(answer)

input("\n\nPress the RETURN key to finish.")#

You might also like