Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson5_1
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
719078ac
authored
Mar 12, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
f64ca328
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
diy.PY
diy.PY
View file @
719078ac
import
turtle
# 导入turtle模块
import
turtle
# 导入turtle模块
pen
=
turtle
.
Pen
()
# 创建画笔
pen
=
turtle
.
Pen
()
# 创建画笔
screen
=
turtle
.
Screen
()
# 从turtle模块中取出画布
screen
.
bgcolor
(
"black"
)
# 用bgcolor()方法,将画布设为黑色
colors
=
[
"green"
,
"red"
,
"orange"
,
"yellow"
]
# 创建列表保存四种颜色
for
i
in
range
(
1
,
300
):
for
i
in
range
(
1
,
300
):
# 变量i对4求余后作为列表索引号并设为pencolor()参数
pen
.
pencolor
(
colors
[
i
%
4
])
pen
.
forward
(
i
)
# 变量1表示画笔移动的距离
pen
.
forward
(
i
)
# 变量1表示画笔移动的距离
pen
.
right
(
91
)
# 右转91
pen
.
right
(
91
)
# 右转91
pen
.
hideturtle
()
# 隐藏画笔
pen
.
hideturtle
()
# 隐藏画笔
...
...
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