Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-1-1_DIY1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
97c6c8f3
authored
May 15, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
bcf8a715
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
2 deletions
diandoudou.py
diy1.py
diandoudou.py
0 → 100644
View file @
97c6c8f3
#导入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
diy1.py
deleted
100644 → 0
View file @
bcf8a715
# 我们都爱夸夸夸
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment