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
3a21091e
authored
Dec 20, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
b7c97470
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
1.py
1.py
View file @
3a21091e
import
turtle
#调用海龟画图库
s
=
1
#设置初始长度变量
pen
=
turtle
.
Pen
()
#设置画笔变量pen
pen
.
speed
(
0
)
#设置画笔速度
for
i
in
range
(
300
):
#有限循环300次,注意括号和英文的冒号
pen
.
forward
(
s
)
#前进s步
pen
.
right
(
91
)
#右转91度
s
=
s
+
1
#变量s每次+1
pen
.
hideturtle
()
#隐藏画笔
turtle
.
done
()
#保存画布
\ No newline at end of file
import
turtle
#调用海龟画图库
pen
=
turtle
.
Pen
()
#设置画笔变量pen
screen
=
turtle
.
Screen
()
#设置画布变量screen
screen
.
bgcolor
(
"black"
)
#设置画布背景颜色
colors
=
[
"red"
,
"orange"
,
"yellow"
,
"green"
]
#设置颜色的列表
pen
.
speed
(
0
)
#设置画笔速度
for
i
in
range
(
1
,
300
):
#有限循环299次,从1开始到299结束
pen
.
pencolor
(
colors
[
i
%
4
])
#用对4取余的方法调用颜色列表里的颜色
pen
.
forward
(
i
)
#前进s步
pen
.
right
(
91
)
#右转91度
pen
.
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