Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson6-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
ed2985d1
authored
May 08, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
26b3b1d4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
14 deletions
d.py
diy.py
d。朋友
d.py
0 → 100644
View file @
ed2985d1
# 臂力挑战赛
# 快用你机灵的小脑瓜想想,如何将刘强和他的臂力值自动插入到hero列表中?
name
=
input
(
"叫啥?"
)
power
=
int
(
input
(
"力量值"
))
hero
=
[
'赵一'
,
30
,
'丁二'
,
37
,
'孙五'
,
52
,
'王猛'
,
89
,
'周亮'
,
98
]
for
i
in
range
(
len
(
hero
)):
if
i
%
2
==
1
and
hero
[
i
]
>=
power
:
hero
.
insert
(
i
-
1
,
name
)
hero
.
insert
(
i
,
power
)
break
print
(
hero
[
-
6
:])
diy.py
View file @
ed2985d1
# 和你的小伙伴用列表讲讲桃园结义的故事,并说说这其中运用了哪些列表知识:
# 和你的小伙伴讲讲史上有名的三英战吕布的故事。然后完成下面挑战,并说说列表切片是什么,怎么用:
# 来,我给你起个头~
# 从前啊,有三个bro,分别是:刘备、关羽、张飞...
# 省略繁杂情节,刘关张三人一起冲入战场,围攻吕布:
bro1
=
"关羽"
a
=
[
'吕布'
]
bro2
=
"刘备"
b
=
[
'袁术'
,
'公孙瓒'
,
'关羽'
,
'张飞'
,
'刘备'
,
'曹操'
]
bro3
=
"张飞"
bros
=
[
"刘备"
,
"关羽"
,
"张飞"
]
c
=
b
[
2
:
5
]
bro1
=
[
"关羽"
,
160
,
8.5
]
a
.
extend
(
c
)
bro2
=
[
"刘备"
,
161
,
9.1
]
print
(
a
)
bro3
=
[
"张飞"
,
166
,
8.3
]
bros
[
0
]
=
"关羽"
bros
[
1
]
=
"刘备"
print
(
bros
)
\ No newline at end of file
# 增加
a
.
insert
(
1
,
"元素"
)
a
.
append
(
"在末尾添加"
)
a
.
extend
(
b
)
#参数是列表
#删除
a
.
pop
()
#删除的索引值,整数是从左到右,负数是从右到左
a
.
remove
()
#删除指定元素,是从左到右
#修改
a
[
0
]
=
"张三"
#查询
# 1 通过索引值来查询
a_1
=
a
[
4
]
#通过切片来查询
b
=
a
[
3
:
6
]
#取左不取右,不写全都取
b
=
[:]
\ No newline at end of file
d。朋友
0 → 100644
View file @
ed2985d1
++ "b/d\343\200\202\346\234\213\345\217\213"
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