import requests as requests
import numpy as np
np.__version__
'1.16.4'
np.random.randint(0,100,10)
array([ 4, 14, 96, 22, 65, 66, 93, 4, 55, 94])
def sum2(x):
ret = 10
for i in x:
ret += i
return ret
x = np.arange(0,10,1)
x
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
%timeit sum2(x)
2.41 µs ± 15.2 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
import numpy as np
l=[10,20,3,4,5,3,55]
type(l)
list
nd=np.array(l)
nd
array([10, 20, 3, 4, 5, 3, 55])
type(nd)
numpy.ndarray
l2=[[1,3,5,7],[2,4,6,8]]
l2
[[1, 3, 5, 7], [2, 4, 6, 8]]
np.array(l2)
array([[1, 3, 5, 7],
[2, 4, 6, 8]])
np.sum(np.array(l2))
36
np.var(l2)
5.25
l3=[[1,2,2,7,8],[2,3,4,5,6]