import time que_list = [] que_list = [ {'question': "以下哪种是多发送者对多接收者参与的通信", 'choices': ["A.收集", "B.扫描", "C.广播", "D.规约"], 'answer': 'B'}, {'question': "四种并行编程风范中,用到了归并思想的是()", 'choices': ["A.相并行", "B.分治并行", "C.流水线并行", "D.工作池并行"], 'answer': 'B'}, ] # question number # print(que_list[0]['question']) # def tran(anss): #question choices translation ABCD # if anss == 0: # anss='A' # elif anss == 1: # anss='B' # elif anss == 2: # anss='C' # elif anss == 3: # anss='D' # else: # print("The answer dosn't set , please check!") # return anss def iputans(n): right_count=0 an = input("input you choices(A,B,C,D):").upper() # ansss = tran(que_list[n]['answer']) ansss = que_list[n]['answer'] if an == ansss: print("true") right_count = 1 else: print("right answer is {}".format(ansss)) return right_count def main(): que_num = len(que_list) que_right = 0 for i in range(que_num): print(que_list[i]['question']) for j in range(4): print(que_list[i]['choices'][j]) count=iputans(i)#count_right answer que_right=que_right+count print("-----------------") time.sleep(2) print("finally right_rate:{}%".format((que_right / que_num)*100)) if __name__ == '__main__': a = time.time() main() b = time.time() print("use time:{}".format(b - a))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)