Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson6-5-2
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
64043b87
authored
Mar 12, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
fecd419e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
10 deletions
diy.py
work.py
diy.py
View file @
64043b87
...
...
@@ -3,17 +3,19 @@
# 请优化刚刚的代码,并增添交互效果,和自动输出最强三人信息的功能~
# 问询处
name
=
input
(
"请输入你的名字"
)
power
=
input
(
"请输入你的臂力"
)
# 归档处
hero
=
[
'赵一'
,
30
,
'丁二'
,
37
,
'孙五'
,
52
,
'王猛'
,
89
,
'周亮'
,
98
,
'张宇'
,
100
]
for
i
in
range
(
len
(
hero
)):
if
i
%
2
==
1
and
hero
[
i
]
>=
int
(
power
):
hero
.
insert
(
i
-
1
,
name
)
hero
.
insert
(
i
,
power
)
break
print
(
hero
)
people
=
input
(
"请问有多少人"
)
for
a
in
range
(
int
(
people
)):
name
=
input
(
"请输入你的名字"
)
power
=
input
(
"请输入你的臂力"
)
for
i
in
range
(
len
(
hero
)):
if
i
%
2
==
1
and
hero
[
i
]
>=
int
(
power
):
hero
.
insert
(
i
-
1
,
name
)
hero
.
insert
(
i
,
int
(
power
))
break
print
(
hero
)
...
...
work.py
0 → 100644
View file @
64043b87
k
=
input
(
"请问你要输入的次数"
)
#询问输入次数
people
=
[]
#设置空列表
name
=
input
(
"请输入你的名字"
)
power
=
input
(
"请输入你的年龄"
)
people
.
append
(
name
)
people
.
append
(
int
(
power
))
print
(
people
)
for
a
in
range
(
int
(
k
)
-
1
):
#设置重复执行次数
name
=
input
(
"请输入你的名字"
)
power
=
input
(
"请输入你的年龄"
)
for
i
in
range
(
len
(
people
)):
if
i
%
2
==
1
and
people
[
i
]
>=
int
(
power
):
people
.
insert
(
i
-
1
,
name
)
people
.
insert
(
i
,
int
(
power
))
break
print
(
people
)
\ 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