4.22 每日一练

以下代码输出是什么? list=['a','b','c','d','e'] print list[10:]
A.  []
B.  程序异常
C.  ['a','b','c','d','e']
D.  输出空

A

 

现有字典 d={"a":26,"g":20,"e":20,"c":24,"d":23,"f":21,"b":25} 请按照字段中的 value 字段进行排序

d={"a":26,"g":20,"e":20,"c":24,"d":23,"f":21,"b":25}
dict(sorted(d.items(),key=lambda x:x[1]))

 

现有列表 alist=[3,1,-4,-2],按期元素的绝对值大小进行排序?

alist=[3,1,-4,-2]
sorted(alist,key=lambda x:abs(x))
alist.sort(key=lambda x:abs(x))
print(alist)

 

posted @ 2020-04-22 23:24  扎小辫的胖虎  阅读(116)  评论(0编辑  收藏  举报