Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_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
952d5800
authored
Jun 12, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
f47689a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
1.py
2.py
diy.py
1.py
0 → 100644
View file @
952d5800
import
turtle
#调用turtle库
pen
=
turtle
.
Pen
()
#使用turtle中的pen画笔
pen
.
speed
(
20
)
#h画笔移动速度
colors
=
[
'red'
,
'yellow'
,
'blue'
,
'green'
]
for
i
in
range
(
1
,
300
):
# i = 0 1 2 3 -----299 #for 循环
pen
.
color
(
colors
[
i
%
4
])
# % 求余
pen
.
forward
(
i
)
pen
.
right
(
91
)
# distance=distance+1 #distance += 1
turtle
.
done
()
#保留画布
\ No newline at end of file
2.py
0 → 100644
View file @
952d5800
for
i
in
range
(
1
,
10
):
#j =1
for
j
in
range
(
1
,
i
+
1
):
#
print
(
j
,
'×'
,
i
,
'='
,(
j
*
i
),
end
=
' '
)
print
()
\ No newline at end of file
diy.py
View file @
952d5800
class
Hero
:
#类名
def
__init__
(
self
,
name
,
hp
,
attack
):
#name hp attack 形参
self
.
level
=
1
#类属性 等级
self
.
name
=
name
self
.
hp
=
hp
#血量
self
.
attack
=
attack
#攻击力
hero01
=
Hero
(
'亚瑟'
,
200
,
30
)
#xiangyu 对象
hero01
.
hp
=
350
print
(
'英雄的名字为:'
+
hero01
.
name
)
print
(
'英雄的血量为:'
+
str
(
hero01
.
hp
))
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