Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson3-5-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
48d8c24d
authored
May 25, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
07858a54
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
turtle.py
turtle.py
0 → 100644
View file @
48d8c24d
import
turtle
#导入turtle模块(turtle模块是一个画图工具)
#背景颜色
screen
=
turtle
.
Screen
()
#创建画布
screen
.
bgcolor
(
"light blue"
)
#设置背景颜色为淡蓝色
#写字
pen
=
turtle
.
Pen
()
#创建画笔pen
pen
.
penup
()
#抬笔
pen
.
goto
(
100
,
-
100
)
#画笔移动到(100,-100)的位置
pen
.
write
(
"Hi,诺依~
\n
python真是太有趣啦~
\n
我也喜欢python~
\n
——悟空 "
,
font
=
(
"Times"
,
20
,
"normal"
))
#写字
pen
.
hideturtle
()
#隐藏画笔
#画爱心
pen1
=
turtle
.
Pen
()
#创建画笔pen1
pen1
.
pencolor
(
"red"
)
#设置画笔颜色为红色
pen1
.
pensize
(
5
)
#设置画笔粗细为5
#借助变量
len
=
60
#将60赋值给变量len
pen1
.
left
(
45
)
#画笔pen1左转45度
pen1
.
forward
(
2
*
len
)
#画笔pen1移动2*len
pen1
.
circle
(
len
,
180
)
#利用circle画一个半径为len的半圆
pen1
.
right
(
90
)
#画笔pen1右转90度
pen1
.
circle
(
len
,
180
)
#利用circle画一个半径为len的半圆
pen1
.
forward
(
2
*
len
)
#画笔pen1移动2*len
pen1
.
hideturtle
()
#隐藏画笔
turtle
.
done
()
#保存画布
\ 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