From 84e83232e648c34937a58015f91333f2c6aaff20 Mon Sep 17 00:00:00 2001 From: ansarsp <67092031+ansarsp@users.noreply.github.com> Date: Sun, 24 Nov 2024 13:38:35 +0530 Subject: [PATCH] Create magic8ball --- 2-control-flow/magic-8-ball/magic8ball | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 2-control-flow/magic-8-ball/magic8ball diff --git a/2-control-flow/magic-8-ball/magic8ball b/2-control-flow/magic-8-ball/magic8ball new file mode 100644 index 0000000..2262177 --- /dev/null +++ b/2-control-flow/magic-8-ball/magic8ball @@ -0,0 +1,36 @@ +import random +name = "Anbu" +question = "Will I learn Python in a month?" +random_number = random.randint(1,9) +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 : + answer = "Error" + +print(random_number) + +if name == "" : + print("Question :" +" "+ question) +else : + print (name + ":" " " + question ) + +if question == "" : + print("Please ask a valid question to the Magic 8-ball.") +else : + print ("Magic 8-Ball's answer" + ":" +" " + answer)