Last active
June 18, 2020 14:01
-
-
Save kw-andy/7ed387b658704ef82b01d814cb7b9969 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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