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
50c92d63
authored
May 21, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
666f93b8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
0 deletions
diy1.py
diy2.py
diy3.py
diy4.py
diy1.py
0 → 100644
View file @
50c92d63
import
turtle
# 导入turtle模块
pen
=
turtle
.
Pen
()
# 调用turtle模块的Pen()方法并赋值给画笔变量pen
screen
=
turtle
.
Screen
()
# 从turtle模块中取出画布
screen
.
bgcolor
(
"black"
)
# 用bgcolor()方法,将画布设为黑色
colors
=
[
"green"
,
"red"
,
"orange"
,
"yellow"
]
for
i
in
range
(
1
,
300
):
# for循环用range()方法重复执行300次
# 变量i对4求余后作为列表的索引号并设为pencolor()参数(画笔每4次画一个颜色)
pen
.
pencolor
(
colors
[
i
%
4
])
pen
.
forward
(
i
)
# 画笔移动的距离
pen
.
right
(
91
)
# 右转91
pen
.
hideturtle
()
# 隐藏画笔
turtle
.
done
()
# 暂停程序,停止画笔绘制
\ No newline at end of file
diy2.py
0 → 100644
View file @
50c92d63
j
=
5
# 列
i
=
7
# 行
print
(
j
,
'*'
,
i
,
'='
,
(
j
*
i
))
# 打印吃列行相乘及结果
\ No newline at end of file
diy3.py
0 → 100644
View file @
50c92d63
i
=
1
# 行
for
j
in
range
(
1
,
10
):
# 列
print
(
j
,
'*'
,
i
,
'='
,
(
j
*
i
),
end
=
" "
)
# 打印出第一行乘法算式
\ No newline at end of file
diy4.py
0 → 100644
View file @
50c92d63
for
i
in
range
(
1
,
10
):
# for循环,行
for
j
in
range
(
1
,
i
+
1
):
# for循环,列,参数2行+1
print
(
j
,
'*'
,
i
,
'='
,
(
j
*
i
),
end
=
' '
)
# 打印出九九乘法算式
print
()
# 打印出
\ 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