|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- 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
- else:
- print("答对了!")
- if b == "-":
- if int(e) != int(a) - int(c):
- print("填写错误,扣一分!")
- score -= 1
- else:
- print("答对了!")
- if b == "×":
- if int(e) != int(a) * int(c):
- print("填写错误,扣一分!")
复制代码
为什么要del a? |
|