Numpy is a library that was based on Scipy
In [1]:
a = [1,2, 3,4,5]
In [2]:
b = []
for i in a:
b.append(i * 2)
print b
In [3]:
a * 2
Out[3]:
In [4]:
b = range(5)
print b
In [5]:
# This code will fail. Uncomment to try it
#a *b
In [6]:
import numpy as np
a2 = np.array([1,2,3,4,5])
print a2
In [7]:
a2 * 2
Out[7]:
In [8]:
b2 = np.arange(5)
print b2
In [9]:
a2 * b2
Out[9]:
In [10]:
a3 = np.array([2, 56, 1, 9, 0])
np.sort(a3)
Out[10]:
In [11]:
np.mean(a2)
Out[11]:
In [12]:
np.average(a2)
Out[12]:
In [12]: