scores = []
data_QAs = {"问题01: ----- A \nA. -- B. -- C. --\n" : "A",
"问题02: ----- B \nA. -- B. -- C. --\n" : "B",
"问题03: ----- C \nA. -- B. -- C. --\n" : "C",
"问题04: ----- A \nA. -- B. -- C. --\n" : "A",
"问题05: ----- B \nA. -- B. -- C. --\n" : "B",
"问题06: ----- C \nA. -- B. -- C. --\n" : "C",
"问题07: ----- A \nA. -- B. -- C. --\n" : "A",
"问题08: ----- B \nA. -- B. -- C. --\n" : "B",
"问题09: ----- C \nA. -- B. -- C. --\n" : "C",
"问题10: ----- A \nA. -- B. -- C. --\n" : "A" }
def isAnswerRight(question, answer, data_QA = data_QAs) -> bool:
if data_QA[question] == answer:
return True
else:
return False
def intelligence(score) -> str:
if score < 60:
return "智商不及格!"
if 60 <= score < 80:
return "智商刚及格!"
if 80 <= score < 100:
return "智商很优秀!"
if score == 100:
return "真是个天才!"
print("-------- 智商检测小游戏 --------\n")
isRun = False
while not isRun:
if input("输入“开始”并按下回车键后游戏正式开始:") in ["开始", "kaishi", "1"]:
isRun = True
print()
print("-" * 30)
for question in data_QAs:
print()
print(question)
in_answer = input("---- 请输入本题答案(A B C):")
while in_answer not in ["A", "B", "C", "a", "b", "c"]:
in_answer = input("---- 请重新输入答案(请勿输入 A B C 以外的其他内容):")
answer = in_answer.upper()
if isAnswerRight(question, answer, data_QAs):
scores.append(10)
print("回答正确,加 10 分!当前总分:", sum(scores), "\n")
else:
scores.append(0)
print("回答错误,不能加分!当前总分:", sum(scores), "\n")
print("-" * 30)
print("\n你的总得分是:", sum(scores), intelligence(sum(scores)))
|