Python 官方文档:入门教程 => 点击学习
常用函数考察: dict(zip(('a','b','c','d','e'),(1,2,3,4,5))) range(10) sorted([i for i in range(10)]) { i:i*i for i in
常用函数考察:
dict(zip(('a','b','c','d','e'),(1,2,3,4,5)))
range(10)
sorted([i for i in range(10)])
{ i:i*i for i in range(10) if i%/2==1 }
[ [i,i*i] for i in range(10)]
函数参数考察:
def f(x,l=[]):
for i in range(x):
l.append(i*i)
print l
f(2)
f(3,[1,2,34])
f(3)
f(4)
#闭包用法考察:
def lamb():
return [lambda x: x*i for i in range(4)]
# lambda x: x*i 作为列表生成式的结果, 最终return了4个 lambda函数组成的列表。
print [m(2) for m in lamb()]
--结束END--
本文标题: python 练习题2
本文链接: https://www.lsjlt.com/news/191125.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0