Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson10-3
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
3d94753f
authored
Feb 04, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
04e717b8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
5 deletions
diy1.py
s.py
s2.py
s3.py
diy1.py
View file @
3d94753f
...
...
@@ -3,14 +3,15 @@
scores
=
{
'语文'
:
89
,
'数学'
:
95
,
'英语'
:
80
}
def
get_average
(
dict_1
)
):
s
core
=
0
def
get_average
(
scores
):
s
um
=
0
for
subject
,
score
in
scores
.
items
():
score
+=
score
print
(
'现在的总分是
%
d'
%
score
)
ave_score
=
score
/
len
(
scores
)
sum
+=
score
# print(sum )
print
(
'现在的总分是
%
d'
%
sum
)
ave_score
=
sum
/
len
(
scores
)
print
(
'平均分是
%
d'
%
ave_score
)
get_average
(
scores
)
\ No newline at end of file
s.py
0 → 100644
View file @
3d94753f
a
=
[
'a'
,
'b'
,
'c'
]
#字典定义 b 语文:88,数学:99 ,英语:100
b
=
{
'语文'
:
88
,
'数学'
:
99
,
'英语'
:
100
}
c
=
{
'张三'
:
b
}
print
(
c
)
'''
#读取数学成绩
# print(b['数学'])
#增加 体育60
b['体育']=60
#print(b)
#将语文成绩修改为99
b['语文'] =99
#删除数学
b.pop('数学')
# print(b)
#遍历字典 键名,值
# for k,v in b.items():
# print(k,v)
#遍历字典的 键名
# for k in b.keys():
# print(k)
#遍历字典的值
for v in b.values():
print(v)
'''
s2.py
0 → 100644
View file @
3d94753f
# 原代码:
city
=
[
'纽约'
,
'华盛顿'
,
'桃源岛'
,
'洛杉矶'
,
'芝加哥'
,
'旧金山'
]
area
=
input
(
'你想去哪里啊?'
)
if
area
in
city
:
print
(
'可以乘坐飞机通往'
+
area
)
else
:
print
(
'没有'
+
area
+
'这座城市'
)
s3.py
0 → 100644
View file @
3d94753f
a
=
10
def
fun1
():
a
=
3
print
(
a
)
def
fun2
():
b
=
a
+
4
print
(
b
)
fun2
()
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