Commit 97c6c8f3 by BellCodeEditor

auto save

parent bcf8a715
Showing with 48 additions and 2 deletions
#导入random 库
import random
#导入turtle库
import turtle as x #把 turtle 定为x
#打开海龟画图窗口
x.TurtleScreen.RUNNING = True
#自定义窗口大小
x.setup(width = 800,height = 450)
#隐藏画笔图标
x.hideturtle()
#设置画笔颜色
x.color('Green')
#让画笔抬起来
x.penup()
#设置画笔位置
x.setpos(-350,0)
#生成一个随机数
rand_number = random.randint(1,100)
#显示用户提示语
x.write('我想到一个1到100之间的数字,来猜猜吧!',font=('微软雅黑',26,'bold'))
#设置用户输入框
guess_number = x.simpledialog.askinteger('猜数字游戏','请输入一个整数')
guess_number = 0
while guess_number != rand_number:
if guess_number == rand_number:
x.clear()
x.write('你猜对啦,游戏结束!',font=('微软雅黑',26,'bold'))
elif guess_number > rand_number:
x.clear()
x.write("你猜大啦,请再猜一次!",font=('微软雅黑',26,'bold'))
else:
x.clear()
x.write("你猜小啦,请再猜一次!",font=('微软雅黑',26,'bold'))
#停止画笔,窗口不要关闭
x.done()
\ No newline at end of file
# 我们都爱夸夸夸
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment