Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson8-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
2301b614
authored
Nov 19, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
0263e615
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
3 deletions
s1.py
s2.py
s4.py
s5.py
s1.py
View file @
2301b614
list_hero
=
[
'猴三'
,
10
,
'猴一'
,
21
,
'猴五'
,
22
,
'猴队长'
,
29
,
'猴七'
,
30
]
import
turtle
turtle
.
pencolor
(
'orange'
)
\ No newline at end of file
turtle
.
fillcolor
(
'yellow'
)
turtle
.
begin_fill
()
for
i
in
range
(
20
):
for
j
in
range
(
4
):
turtle
.
forward
(
100
)
turtle
.
left
(
90
)
turtle
.
left
(
18
)
turtle
.
end_fill
()
turtle
.
hideturtle
()
turtle
.
done
()
\ No newline at end of file
s2.py
0 → 100644
View file @
2301b614
import
turtle
turtle
.
fillcolor
()
turtle
.
pencolor
(
'red'
)
#定义画笔
turtle
.
fillcolor
(
'yellow'
)
#填充
turtle
.
begin_fill
()
#开始填充
for
i
in
range
(
20
):
#20次
for
j
in
range
(
4
):
#40
turtle
.
forward
(
100
)
turtle
.
left
(
90
)
turtle
.
left
(
18
)
turtle
.
end_fill
()
#结束填充
turtle
.
hideturtle
()
#隐藏箭头
turtle
.
done
()
\ No newline at end of file
s4.py
0 → 100644
View file @
2301b614
'''
字典名:dt
张三 18
李四 19
输出张三值
字典名={键名:值} #字典的格式 '''
#定义字典dt
dt
=
{
'张三'
:
18
,
'李四'
:
19
}
#输出张三的值
#print(dt['张三']) #字典[键名]
#将‘张三 ’的值改为20
dt
[
'张三'
]
=
20
#print(dt['张三'])
#增加'王五' 21
dt
[
'王五'
]
=
21
#如果王五存在于字典中,它就修改王五的值,否则,它就自动增加王五这一项
#遍历字典dt
for
k
in
dt
:
print
(
k
)
'''
# 提取猴队长的臂力值
print(dict_hero['猴队长'])
# 修改猴七的臂力值为32
dict_hero['猴七']=32
print(dict_hero)
'''
\ No newline at end of file
s5.py
0 → 100644
View file @
2301b614
# 神奇百货中的物品已经帮你创建好啦,接下来要看你的了~
dict
=
{
'可口可乐'
:
3
,
'旺仔牛奶'
:
4
,
'农夫山泉'
:
1
,
'辣条'
:
3
,
'巴西烤肉'
:
2
,
'果冻'
:
4
,
'乐事'
:
5
,
'奥利奥'
:
10
,
'巧克力'
:
6
}
k
=
input
(
'你想买什么啊?'
)
if
k
in
dict
:
print
(
k
+
'价格'
+
str
(
dict
[
k
])
+
'元'
)
else
:
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