Skip to content

Instantly share code, notes, and snippets.

@kw-andy
Last active June 18, 2020 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kw-andy/7ed387b658704ef82b01d814cb7b9969 to your computer and use it in GitHub Desktop.
Save kw-andy/7ed387b658704ef82b01d814cb7b9969 to your computer and use it in GitHub Desktop.
import que_ans
from termcolor import colored
def question_answer():
good = 0
bad = 0
while True:
qa = que_ans.QA
question,answer = qa.new()
try:
print("{} = ?".format(question))
user_answer = input()
if int(user_answer) != answer:
print(colored("Wrong! {} = {}","red").format(question,answer))
bad+=1
else:
print(colored("Right!","green"))
good+=1
except:
return "Your score is {} / {}".format(good,good+bad)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment