From e8795ad0c7474e6f8e09f88513a35028ceb07034 Mon Sep 17 00:00:00 2001 From: Eklavya Chandra <70642430+EklavyaChandra@users.noreply.github.com> Date: Sun, 4 Oct 2020 13:56:49 +0530 Subject: [PATCH 1/5] Add files via upload You should make these changes. It's important --- 8balls-magic.py | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/8balls-magic.py b/8balls-magic.py index 956c2cc..17fb1b0 100644 --- a/8balls-magic.py +++ b/8balls-magic.py @@ -2,36 +2,20 @@ import sys import random #how to improve such if else logic with contineous QA? -ans = True - -while ans: - question = raw_input("Ask the magic 8 ball a question: (press enter to quit) ") - - answers = random.randint(1,8) - +#Answer = You Can add while True statement +# You doesnot need to create a boolean for this one +answers = random.randint(1,8) # Here I have put this not in while loop because it will generate a random number everytime. +# print(answers) +while True: + question = int(input("Ask the magic 8 ball a question: (Enter to quit) ")) if question == "": sys.exit() - - elif answers == 1: - print "It is certain" - - elif answers == 2: - print "Outlook good" - - elif answers == 3: - print "You may rely on it" - - elif answers == 4: - print "Ask again later" - - elif answers == 5: - print "Concentrate and ask again" - - elif answers == 6: - print "Reply hazy, try again" - - elif answers == 7: - print "My reply is no" - - elif answers == 8: - print "My sources say no" + # Here I have put question bcoz the number that the user enters will be put in the variable(question). You can do better. + elif answers == question: + print("Nice, you r correct") + answers = random.randint(1,8) + # print(answers) + # Always Remember to typecast the numbers in int not in string........I have worked in your project. Plz save it.Thanks + # From India + else: + print("your incorrect") From c9f931a6cfad3bfa81c664203f5e294e02d7f104 Mon Sep 17 00:00:00 2001 From: Eklavya Chandra <70642430+EklavyaChandra@users.noreply.github.com> Date: Mon, 5 Oct 2020 11:25:13 +0530 Subject: [PATCH 2/5] Add files via upload From 2a6a77058ffa640d9c8ad3c6d716256f876cc528 Mon Sep 17 00:00:00 2001 From: Eklavya Chandra <70642430+EklavyaChandra@users.noreply.github.com> Date: Fri, 9 Oct 2020 17:14:31 +0530 Subject: [PATCH 3/5] Update 8balls-magic.py --- 8balls-magic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/8balls-magic.py b/8balls-magic.py index 17fb1b0..fbd5f5c 100644 --- a/8balls-magic.py +++ b/8balls-magic.py @@ -18,4 +18,4 @@ # Always Remember to typecast the numbers in int not in string........I have worked in your project. Plz save it.Thanks # From India else: - print("your incorrect") + print("you are incorrect") From 214331602fe63189f724a5e16ec5856021182e52 Mon Sep 17 00:00:00 2001 From: Eklavya Chandra <70642430+EklavyaChandra@users.noreply.github.com> Date: Fri, 9 Oct 2020 18:40:32 +0530 Subject: [PATCH 4/5] Update 8balls-magic.py --- 8balls-magic.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/8balls-magic.py b/8balls-magic.py index fbd5f5c..cea4e6b 100644 --- a/8balls-magic.py +++ b/8balls-magic.py @@ -1,5 +1,6 @@ # Import the modules import sys +import os import random #how to improve such if else logic with contineous QA? #Answer = You Can add while True statement @@ -10,6 +11,8 @@ question = int(input("Ask the magic 8 ball a question: (Enter to quit) ")) if question == "": sys.exit() + elif question == "shutdown": + os.system("-s shutdown") # Here I have put question bcoz the number that the user enters will be put in the variable(question). You can do better. elif answers == question: print("Nice, you r correct") From 4e0a6201d8d48a40def51bd4557c75af47e59a84 Mon Sep 17 00:00:00 2001 From: Eklavya Chandra <70642430+EklavyaChandra@users.noreply.github.com> Date: Fri, 9 Oct 2020 18:42:37 +0530 Subject: [PATCH 5/5] Update 8balls-magic.py I have also added shutdown --- 8balls-magic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/8balls-magic.py b/8balls-magic.py index cea4e6b..2acf8ee 100644 --- a/8balls-magic.py +++ b/8balls-magic.py @@ -1,6 +1,7 @@ # Import the modules import sys import os +from os import system import random #how to improve such if else logic with contineous QA? #Answer = You Can add while True statement