From 94cc9fe13659a4569fb6c3b588e7be0ae8f5f3c6 Mon Sep 17 00:00:00 2001 From: Daniel <28221676+DCodeAus@users.noreply.github.com> Date: Fri, 21 Oct 2022 15:21:35 +1100 Subject: [PATCH] Added 8 ball program to list of python projects --- Python/Magic8Ball.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Python/Magic8Ball.py diff --git a/Python/Magic8Ball.py b/Python/Magic8Ball.py new file mode 100644 index 0000000..4eb9b21 --- /dev/null +++ b/Python/Magic8Ball.py @@ -0,0 +1,39 @@ +import random +#future: name can be changed to input to get a name from the users input +name = "YourName" +#future: question as above can be redone to ask user +question="Are we living in a simulation?" +#sets up empty string for answer is then populated with the elif statements +answer="" +#random number assigner between 1 and 9 +random_number =random.randint(1,9) + +#print(random_number) +print(name + " asks: " + question) +if name =="": + print("Question" + question) +if question=="": + print("Error no question asked") +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." + +else: + print("Error") + +print("Magic 8 Ball's Answer: " + answer) \ No newline at end of file