import random as r
import turtle as t
big = 1000
small = 1
a = r.randint(small, big)
for c in range(20):
try:
b = int(t.textinput('猜数字小游戏', '请猜一个%s~%s之间的数字' % (small, big)))
# t.undo()
t.dot(10000, 'white')
if a == b:
t.write('竟然猜中了,老实说,你是不是挂', font=(None, 25))
t.up()
t.goto(0, -100)
t.down()
t.write('你用了%s局' % (c + 1), font=(None, 25))
break
elif a > b:
t.write('你猜小了', font=(None, 25))
small = b
elif a < b:
t.write('你猜大了', font=(None, 25))
big = b
except:
t.write('请认真游戏', font=(None, 25))
t.done()
zizhan - 猜数字游戏
最新推荐文章于 2024-04-24 15:21:54 发布