forked from shakkaist/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
8balls-magic.py
25 lines (25 loc) · 1017 Bytes
/
8balls-magic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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
# 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 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")
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("you are incorrect")