使用Python中的reduce()函数求积的实例
作者:dou_being 时间:2021-08-14 04:35:47
编写一个prod()函数,可以接受一个list并利用reduce()求积。
from functools import reduce
def prod(x,y):
return x * y
L = reduce(prod,[3,5,7,9])
print(L)
打印结果如下:
来源:https://blog.csdn.net/dou_being/article/details/79921983
标签:Python,reduce,求积
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
使用Python处理KNN分类算法的实现代码
2023-11-03 07:03:07
![](https://img.aspxhome.com/file/2023/4/63244_0s.png)
Python爬取成语接龙类网站
2022-04-09 07:29:58
![](https://img.aspxhome.com/file/2023/5/87795_0s.png)
Python利用imshow制作自定义渐变填充柱状图(colorbar)
2023-07-14 00:27:57
![](https://img.aspxhome.com/file/2023/8/109498_0s.png)
Scrapy元素选择器Xpath用法汇总
2021-09-11 11:42:58
在ASP.NET 2.0中操作数据之四十:自定义DataList编辑界面
2023-07-07 04:45:20
![](https://img.aspxhome.com/file/2023/0/75550_0s.png)
利用Python Matlab绘制曲线图的简单实例
2021-05-16 07:21:38
![](https://img.aspxhome.com/file/2023/4/78494_0s.png)
Python计算三角函数之asin()方法的使用
2023-08-04 22:31:46
Django前端BootCSS实现分页的方法
2023-12-21 01:45:34
![](https://img.aspxhome.com/file/2023/8/103348_0s.gif)
用户研究角度看设计(2):用户为何视若无睹
2009-01-09 12:51:00
![](https://img.aspxhome.com/file/UploadPic/20091/9/1-84s.jpg)
python 使用tkinter+you-get实现视频下载器
2023-08-15 18:40:25
![](https://img.aspxhome.com/file/2023/0/81560_0s.png)
纯Python开发的nosql数据库CodernityDB介绍和使用实例
2022-10-21 12:16:05
![](https://img.aspxhome.com/file/2023/1/72031_0s.jpg)
PyTorch 多GPU下模型的保存与加载(踩坑笔记)
2023-07-20 15:39:18
pyqt和pyside开发图形化界面
2022-05-06 18:10:08
Python实战之手写一个搜索引擎
2023-07-11 21:16:49
![](https://img.aspxhome.com/file/2023/3/67323_0s.jpg)
将python字符串转化成长表达式的函数eval实例
2022-08-25 18:27:23
PDO::_construct讲解
2023-06-06 03:22:31
Keras模型转成tensorflow的.pb操作
2023-12-22 13:10:34
Matlab求解数组中的最大值及它所在的具体位置
2023-08-11 18:55:11
![](https://img.aspxhome.com/file/2023/2/93762_0s.png)
浅谈Scrapy框架普通反爬虫机制的应对策略
2023-07-14 17:11:40
速记Python布尔值
2022-04-23 10:02:17