Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-1-2_DIY1
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
a06aeca2
authored
May 05, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
1b141fc5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
star.py
star.py
View file @
a06aeca2
bro1
=
"关羽"
student1
=
{
"语文"
:
91
,
"数学"
:
88
,
"英语"
:
85
}
#创建一个字典student1,并且有键和值(悟空成绩)
bro2
=
"刘备"
student2
=
{
"语文"
:
95
,
"数学"
:
85
,
"英语"
:
87
}
#创建一个字典student2,并且有键和值(小贝成绩)
bro3
=
"张飞"
student3
=
{
"语文"
:
98
,
"数学"
:
89
,
"英语"
:
90
}
#创建一个字典student3,并且有键和值(诺伊成绩)
bros
=
[
"刘备"
,
"关羽"
,
"张飞"
]
score
=
{
"悟空"
:
student1
,
"小贝"
:
student2
,
"诺伊"
:
student3
}
#创建一个字典score,并且有键和值
bro1
=
[
"关羽"
,
160
,
8.5
]
while
True
:
#while循坏
bro2
=
[
"刘备"
,
161
,
9.1
]
name
=
input
(
"请输入查询成绩的姓名,输入q退出查询"
)
#输入查询成绩的姓名,输入q则退出查询并且赋值给变量name
bro3
=
[
"张飞"
,
166
,
8.3
]
if
name
in
score
:
#如果变量name在字典score里
bros
[
0
]
=
"关羽"
info_score
=
score
[
name
]
#把字典score里的变量name赋值给变量info_score
bros
[
1
]
=
"刘备"
print
(
"*"
*
20
)
#输出
print
(
bros
)
for
k
,
v
in
info_score
.
items
():
#输出字典info_score中所有的键值对
\ No newline at end of file
print
(
k
,
v
)
#输出键值对
elif
name
==
"q"
:
#或者变量name等于q
print
(
"查询结束"
)
#输出
break
#结束程序
else
:
#否则
print
(
"输入错误"
)
#输出
print
(
"*"
*
20
)
#输出
\ 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