Commit 6f900850 by BellCodeEditor

auto save

parent 7399a42a
Showing with 27 additions and 20 deletions
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
name='谭秋实'
age=11
print(f'我叫{name},今年{age}岁')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment