首页 > 移动平台 > 详细

小学2年级数学混合运算手机打卡训练

时间:2020-05-23 00:37:14      阅读:79      评论:0      收藏:0      [点我收藏+]
import math
import random
score=0
num=eval(input("questions:"))
questions=[]
errors=[]
for i in range(num): 
    a=random.randint(2,9)
    b=random.randint(2,9)
    c=random.randint(2,9)
    op1=random.choice([ + , - ])
    op2=random.choice([ + , * , - , * ])
    exp= str(a) + op1 + str(b) + op2 + str(c)
    questions.append(exp)
for i in range(num):
    exp=questions[i]
    d=eval(exp)
    ans=eval(input(str(i)+": "+exp+" : "))
    if d == ans:
        score += 1
        print("v")
    else:
        print("x")
        errors.append(i)

print("1: score = ",score)
for i in errors:
    exp=questions[i]
    d=eval(exp)
    ans=eval(input(str(i)+": "+exp+" : "))
    if d == ans:
        score += 1
        print("v")
    else:
        print("x")
if len(errors)>0:
    print("2:score = ",score)

 

小学2年级数学混合运算手机打卡训练

原文:https://www.cnblogs.com/xiexiaokui/p/12940019.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!