-
-
Save codecademydev/366bafc5734db7c69c25100342b6bfae to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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