如下所示:
# the basic ways = 0for x in range(10): s += x# the right ways = sum(range(10))# the basic ways = 1for x in range(1, 10): s *= x# the other wayfrom operator import mulreduce(mul, range(1, 10))
以上這篇在python中實(shí)現(xiàn)對(duì)list求和及求積就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持武林站長(zhǎng)站。
|
新聞熱點(diǎn)
疑難解答
圖片精選