问答程式
执行:py 17+TAB键
#from question import Question(只引入QUESTION)#imoprt question (整个QUESTION.py引入)from question import Questiontest = [ "1+1=?\n(a) 2\n(b) -2\n(c) 妈妈咪呀~我肚子饿了\n\n", "等边三角形的三角和?\n(a) 90度~我左看右看怎么都不奇怪\n(b) 180度~欢乐的角度\n(c) 360度~旋转与跳跃\n\n", "小白兔是甚么颜色?\n(a) 我没看过怎么知道\n(b) 大便色~因为黑熊嘿嘿\n(c) 白色~阿就告诉你是小白兔了阿\n\n"]questions = [ Question(test[0],"a"), Question(test[1],"b"), Question(test[2],"c")]def run_test(questions): score = 0 for question in questions: answer = input(question.description) if answer == question.answer: score += 1 print("你获得" + str(score) + "分,共" + str(len(questions)) +"题")run_test(questions)


