|

楼主 |
发表于 2023-3-9 20:25:08
|
显示全部楼层
好的- 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 < b:
- del a
- a = str(r.randint(b,scope_2))
- else:
- pass
- if b == "-":
- if a < b:
- del a
- a = str(r.randint(b,scope_2))
- else:
- pass
- d = a + b + c
- e = input(d + "=")
- if b == "+":
- if int(e) != int(a) + int(b):
- print("填写错误,扣一分!")
- score -= 1
- if b == "-":
- if int(e) != int(a) - int(b):
- print("填写错误,扣一分!")
- score -= 1
- if b == "×":
- if int(e) != int(a) * int(b):
- print("填写错误,扣一分!")
- score -= 1
- if b == "÷":
- if int(e) != int(a) // int(b):
- print("填写错误,扣一分!")
- score -= 1
- print(f"题目已结束,你的得分为{score}。")
复制代码 |
|