>>> import numpy as np
>>>
>>> a = [1,2,3,4]
>>> b = np.array(a)
>>> print(type(a))
<class 'list'>
>>> print(type(b))
<class 'numpy.ndarray'>
>>> print(a)
[1, 2, 3, 4]
>>> print(b)
[1 2 3 4]
>>> print(a[0])
1
>>> print(b[0])
1
>>> print(a[0:3])
[1, 2, 3]
>>> print(b[0:3])
[1 2 3]
>>> print(a+1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "int") to list
>>> print(b+1)
[2 3 4 5]
>>> print(a*2)
[1, 2, 3, 4, 1, 2, 3, 4]
>>> print(b*2)
[2 4 6 8]
>>> print(a+a)
[1, 2, 3, 4, 1, 2, 3, 4]
>>> print(b+b)
[2 4 6 8]
>>>
>>> import numpy as np
>>>
>>> a = [[1,1,1],[2,2,2],[3,3,3]]
>>> b = np.array(a)
>>>
>>> print(a)
[[1, 1, 1], [2, 2, 2], [3, 3, 3]]
>>> print(b)
[[1 1 1]
[2 2 2]
[3 3 3]]
>>>
>>> print(b.shape)
(3, 3)
>>> print(b * 2)
[[2 2 2]
[4 4 4]
[6 6 6]]
>>>
Numpy random