本帖最后由 歌者文明清理员 于 2023-3-9 21:01 编辑
还会报错,我研究研究
研究完毕,又改了改你的代码,结果如下import random as r
time = int(input("请输入题目数量(单位:道)"))
scope_1 = int(input("请输入起始范围:"))
scope_2 = int(input("请输入截止范围:"))
score = time
print("温馨提示:因除法运算采用地板除除法防止小数,所以请在运算时省略余数!")
for i in range(time):
operator = ["+","-","×","÷"]
a = str(r.randint(scope_1,scope_2))
b = r.choice(operator)
c = str(r.randint(scope_1,scope_2))
if b == "÷":
if a < c:
del a
a = str(r.randint(int(c),scope_2))
else:
pass
if b == "-":
if a < c:
del a
a = str(r.randint(int(c),scope_2))
else:
pass
d = a + b + c
e = input(d + "=")
if b == "+":
if int(e) != int(a) + int(c):
print("填写错误,扣一分!")
score -= 1
if b == "-":
if int(e) != int(a) - int(c):
print("填写错误,扣一分!")
score -= 1
if b == "×":
if int(e) != int(a) * int(c):
print("填写错误,扣一分!")
score -= 1
if b == "÷":
if int(e) != int(a) // int(c):
print("填写错误,扣一分!")
score -= 1
print(f"题目已结束,你的得分为{score}。")
@一点沙 |