Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created December 7, 2021 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/366bafc5734db7c69c25100342b6bfae to your computer and use it in GitHub Desktop.
Save codecademydev/366bafc5734db7c69c25100342b6bfae to your computer and use it in GitHub Desktop.
Codecademy export
import random
name = ""
question = "Will this work?"
answer = ""
random_number = random.randint(0,12)
# print(random_number)
if random_number == 1:
answer = "Yes - definitely."
elif random_number == 2:
answer = "It is decidedly so."
elif random_number == 3:
answer = "Without a doubt."
elif random_number == 4:
answer = "Reply hazy, try again."
elif random_number == 5:
answer = "Ask again later."
elif random_number == 6:
answer = "Better not tell you now."
elif random_number == 7:
answer = "My sources say no."
elif random_number == 8:
answer = "Outlook not so good."
elif random_number == 9:
answer = "Very doubtful."
elif random_number == 10:
answer = "Most certainly not."
elif random_number == 11:
answer = "It is certain."
elif random_number == 12:
answer = "Uncertain."
else:
answer = "Error"
if question == "":
print("You need to ask a question.")
elif name == "":
print("Question:",question)
print("Magic 8-ball's answer:",answer)
else:
print(name,"asks:",question)
print("Magic 8-ball's answer:",answer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment