Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson5_7
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
c95fe449
authored
Nov 25, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
3dc86572
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
3 deletions
diy2.py
diy2.py
View file @
c95fe449
i
=
5
# 行
#第一题
j
=
3
# 列
# 和你的小伙伴用列表讲讲桃园结义的故事,并说说这其中运用了哪些列表知识:
# 使用变量i和j,代替乘法算式里面的元素,打印出单个乘法算式
# 来,我给你起个头~
# 从前啊,有三个bro,分别是:刘备、关羽、张飞...
# bro1="关羽"
# bro2="刘备"
# bro3="张飞"
# bros=["刘备","关羽","张飞"]
# bro1=["关羽",160,8.5]
# bro2=["刘备",161,9.1]
# bro3=["张飞",166,8.3]
# #根据智力评分对列表bros进行重新排列
# bros[0]="关羽"
# bros[1]="刘备"
# bros[2]="张飞"
# print(bros)
#第二题
#注意这里开始,字符串用单引号哦
# b=['袁术','夏侯惇','曹操','关羽']
# # #利用方法1:删除关羽,输出列表b
# b.pop(-1)
# # #利用方法2:删除夏侯惇,输出列表b
# b.remove("夏侯惇")
# # #利用方法3:删除曹操,输出列表b
# b.pop(1)
# print(b)
# #第三题
# #关羽上前迎战,战场上除了华雄还有关羽,吕布
# a=['华雄']
# # #方法1:关羽填到a列表中
# a.append("关羽")
# # # 方法2:吕布添加进a列表
# a.insert(2,"吕布")
# print(a)
# #第四题
# c = ["周瑜","诸葛孔明","曹操","刘备","关羽","张飞","于禁"]
# # #利用切片知识,将桃园三英雄提取出来
# c[3:6]
# print(c[3:6])
# #第五题
# # 臂力挑战赛
# # 快用你机灵的小脑瓜想想,如何将刘强和他的臂力值自动插入到hero列表中?
name
=
'吴克'
power
=
66
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
)
# #第六题
# # 古代测量臂力是靠不同重量的石锁,只能测整数哦。
# # 最小的石锁是30公斤最大的石锁是100公斤,注意输入的数字哦
# # 问询处
name
=
?
power
=
?
# 归档处
hero
=
[
'赵一'
,
30
,
'丁二'
,
37
,
'孙五'
,
52
,
'王猛'
,
89
,
'周亮'
,
98
,
'张宇'
,
100
for
i
in
range
(
len
(
hero
)):
print
(
hero
[
-
6
:])
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