Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson9_4
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
0a7d456a
authored
Sep 30, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
f6cbf097
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
demo.py
demo.py
View file @
0a7d456a
#创建字典存储成绩
student1
=
{
"语文"
:
88
,
"数学"
:
90
,
"英语"
:
99
}
student2
=
{
"语文"
:
88
,
"数学"
:
90
,
"英语"
:
99
}
student3
=
{
"语文"
:
88
,
"数学"
:
90
,
"英语"
:
99
}
student4
=
{
"语文"
:
88
,
"数学"
:
90
,
"英语"
:
99
}
#创建学生字典
score
=
{
"张三"
:
student1
,
"李四"
:
student2
,
"王五"
:
student3
,
"马三"
:
student4
}
#开始循环输入查找
while
True
:
print
(
"请输入要查询的名字,退出请输入q"
)
name
=
input
(
"请输入要查询的名字:"
)
print
(
"*"
*
30
)
#判断所输入的名字是否在学生字典
if
name
in
score
:
#创建变量存储对应的成绩
info
=
score
[
name
]
#循环遍历字典,打印成绩
for
k
,
v
in
info
.
items
():
print
(
k
,
v
)
print
(
"*"
*
30
)
elif
name
==
q
:
break
else
:
print
(
"输入错误,请重新输入!"
)
print
(
"程序结束!"
)
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