python列表相乘函数map函数
来源:互联网 发布:全员网络闯关赛 编辑:程序博客网 时间:2024/05/10 19:57
lt=range(5,10)
lw=range(8,13)
print lt
print lw
def mul(f,t,w):
i=0
ltt=[]
while i<len(t):
ltt.append(f(t[i],w[i]))
i+=1
return ltt
def p(a,b):
return a*b
li=[]
li=mul(p,lt,lw)
print li
print '-------------'
def p2(x,y):
return x*y
li=range(1,10)
lt=range(5,14)
print li
print lt
lt=map(p2,li,lt)
print lt
>>>[5, 6, 7, 8, 9]
[8, 9, 10, 11, 12]
[40, 54, 70, 88, 108]
-------------
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[5, 6, 7, 8, 9, 10, 11, 12, 13]
[5, 12, 21, 32, 45, 60, 77, 96, 117]
0 0
- python列表相乘函数map函数
- python列表推导 和 内置函数map,filter 效率对比
- python的map、filter、reduce函数以及列表解析式
- Python内置函数-map()函数
- python map()函数
- Python-map()函数
- python map函数用法
- Python中map()函数
- python中map()函数
- python中的map()函数
- python map 函数
- python---map函数
- Python中的map函数
- python:map函数练习
- python map函数
- python map函数
- python-内置函数map()
- python-内置函数map()
- 数据结构实验之栈三:后缀式求值
- linux驱动学习笔记(一)
- week10---11月10日 JS基础(三)
- tableViewCell 内部按钮点击事件 和 cell 高度变化操作
- 关于映射模式和双缓冲的一些细节
- python列表相乘函数map函数
- 在 Xcode 7 中安装 Alcatraz
- HomeBrew的安装和简单使用
- 数据结构实验之栈四:括号匹配
- CSS+DIV定位分析(relative,absolute,static,fixed)
- Java基础---包装类
- Win10编译OpenCV2.4.9+CUDA7.5的方法
- Ubuntu下搭建Nginx+Uwsgi+Python+Mysql开发环境
- 数据结构实验之栈五:下一较大值(一)