Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson3-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
77946246
authored
Mar 18, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
df16bf77
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
4 deletions
diy1.py
diy2.py
diy3.py
diy1.py
View file @
77946246
# 利用write()帮助悟空给诺依回信吧~
import
turtle
screen
=
turtle
.
Screen
()
screen
.
bgcolor
(
"light blue"
)
len
=
screen
.
textinput
(
"100
"
,
"100"
)
len
=
int
(
len
)
#
screen=turtle.Screen()
#
screen.bgcolor("light blue")
#len=screen.textinput("想画多大的爱心啊
","100")
#
len=int(len)
pen
=
turtle
.
Pen
()
pen
.
write
(
"你好
\n
SB."
,
font
=
(
"Times"
,
30
,
"normal"
))
pen
.
hideturtle
()
...
...
diy2.py
0 → 100644
View file @
77946246
import
turtle
#背景颜色
screen
=
turtle
.
Screen
()
screen
.
bgcolor
(
"light blue"
)
#文字画笔
pen
=
turtle
.
Pen
()
#先抬笔,再移动画笔位置
pen
.
penup
()
pen
.
goto
(
100
,
-
100
)
#设置文字内容及格式
pen
.
write
(
"hello world
\n
您好啊!
\n
好久不见了,别来无恙!
\n
long time no see"
,
font
=
(
"Times"
,
20
,
"normal"
))
pen
.
hideturtle
()
#弹窗输入文本,以及转换数据类型
len
=
screen
.
textinput
(
"你想画多大的爱心?"
,
"请输入数字"
)
len
=
int
(
len
)
#爱心画笔的创建和设置
pen1
=
turtle
.
Pen
()
pen1
.
pensize
(
5
)
pen1
.
pencolor
(
"red"
)
#自定义画爱心函数
def
draw
(
len
):
pen1
.
left
(
45
)
pen1
.
forward
(
len
*
2
)
pen1
.
circle
(
len
,
180
)
pen1
.
right
(
90
)
pen1
.
circle
(
len
,
180
)
pen1
.
forward
(
len
*
2
)
#调用函数画爱心,利用变量修改爱心大小
draw
(
len
)
#抬笔换位置再画
pen1
.
penup
()
pen1
.
goto
(
200
,
300
)
#落笔再画爱心
pen1
.
pendown
()
draw
(
20
)
#隐藏画笔
pen1
.
hideturtle
()
#保存画布
turtle
.
done
()
diy3.py
0 → 100644
View file @
77946246
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