电脑随机出算术题
import turtle as timport random as r
for i in range(5):
a = r.randint(1,100)
b = r.randint(1,100)
c = r.randint(1,4)
if c == 1 :
d = "+"
e = a + b
elif c == 2 :
d = "-"
e = a - b
elif c == 3 :
d = "*"
e = a * b
else :
d = "//"
e = a // b
answer = t.numinput("{}{}{}=?".format(a,d,b),"请输入答案:")
if answer == e :
print("回答正确")
else :
print("回答错误")
t.done()
页:
[1]