Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson9_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
6f900850
authored
Sep 12, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
7399a42a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
20 deletions
diy3.py
dvojfdi.py
diy3.py
View file @
6f900850
student1
=
{
'语文'
:
91
,
'数学'
:
88
,
'英语'
:
85
}
# # 绝对值:
student2
=
{
'语文'
:
97
,
'数学'
:
98
,
'英语'
:
90
}
# # 一个正数的绝对值是它本身,例如4的绝对值是4;
student3
=
{
'语文'
:
95
,
'数学'
:
100
,
'英语'
:
93
}
# # 一个负数的绝对值是它的相反数,例如-4的绝对值是4.
score
=
{
'悟空'
:
student1
,
'诺依'
:
student2
,
'小贝'
:
student3
}
# a=[1,23,'53',6,4,'98']
# print(max(a))
# print(min(a))
map
(
,
)
映射,用于对列表中的每个元素执行相同的内容
函数
可迭代序列(容器)
# 查询并打印出输入的名字对应的所有科目的成绩
要用
list
()
转换为列表
while
True
:
//
取整
5
//
3
的结果为
1
name
=
input
(
"名字:"
)
%
取余
5
%
3
的结果为
2
5
除以
3
=
1.
.....
2
if
name
in
score
:
all
()
用于判断列表中元素的逻辑值,
a
=
score
[
name
]
如果所有元素的逻辑值为
True
,则返回
True
;
print
(
'*'
*
30
)
如果有元素的逻辑值为
False
,则返回
False
。
for
k
,
v
in
a
.
items
():
any
()
如果列表中元素逻辑值有一个为
True
,则返回
True
;
print
(
k
,
v
)
如果列表中元素逻辑值都为
False
,则返回
False
。
break
find
(
,
,
)
用于字符串的查找,返回第一个子字符串的索引值
else
:
要搜索的子字符串
开始
结尾
print
(
'输入错误'
)
(
0
)
(字符串的长度)
\ No newline at end of file
f
-
strings
格式化:在字符串模板前面加了
f
,然后使用占位符
{},
里面直接放入对应的数据对象。
rindex
()
用于查找指定的元素在序列对象中最后一个出现的索引值;
从序列对象的末尾开始向前搜索
\ No newline at end of file
dvojfdi.py
View file @
6f900850
name
=
'谭秋实'
age
=
11
print
(
f
'我叫{name},今年{age}岁'
)
\ 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