1. 程式人生 > >9.29作業

9.29作業

col range code .com from etime info sta ()

a = list(range(10))
b =list(range(0,50,5))
c=[]
for i in range(len(a)):
    c.append (a[i] + b[i])
    print(a,b,c)

運行結果

技術分享圖片

def pySum(n):
    a = list(range(n))
    b = list(range(0,5*n,5))
    c = []
    for i in range(len(a)):
        c.append(a[i]**2+b[i]** 3)
    return(c)
print(pySum(10))

import numpy
def npSum(n): a = numpy.arange(10) b = numpy.arange(0,50,5) c = a+b print(a, b,c) return(c) print(npSum(10)) from datetime import datetime start = datetime.now() pySum(100000) delta = datetime.now()-start print(delta) start = datetime.now() npSum(100000) delta = datetime.now()-start print(delta)

運行結果

技術分享圖片

9.29作業