Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson8-5
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
35609509
authored
4 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
789165dc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
diy5.py
diy5.py
View file @
35609509
#已有成绩字典score
score
=
{
"小明"
:
80
,
"小红"
:
90
}
#请用户输入姓名name
name
=
input
(
"请输入姓名:"
)
#请用户输入成绩s
s
=
input
(
"请输入成绩:"
)
#如果name在score中:
if
name
in
score
:
#判断s是否比之前的值大,如果s大于字典中name对应的值:
if
int
(
s
)
>
score
[
name
]:
#把score中name对应的值更新为s,注意s应为整数
score
[
name
]
=
int
(
s
)
#输出score
print
(
score
)
#否则:
else
:
#输出score
print
(
score
)
#否则:
else
:
#新建一个name键,存储对应成绩,注意s应为整数
score
[
name
]
=
int
(
s
)
#输出score
print
(
score
)
This diff is collapsed.
Click to expand it.
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