Skip to content

Some grammatical mistakes #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 19 additions & 31 deletions 8balls-magic.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
# Import the modules
import sys
import os
from os import system
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"
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")