>>> xx = x * x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't multiply sequence by non-int of type 'list'
>>> xx = dot(x,x)
>>> xx
91
>>> ixx = inner(x,x)
>>> ixxx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'ixxx' is not defined
>>> ixx
91
>>> vxx = vdot(x,x)
>>> vxx
91
>>> outer(x,x)
array([[ 1, 2, 3, 4, 5, 6],
[ 2, 4, 6, 8, 10, 12],
[ 3, 6, 9, 12, 15, 18],
[ 4, 8, 12, 16, 20, 24],
[ 5, 10, 15, 20, 25, 30],
[ 6, 12, 18, 24, 30, 36]])
>>> y = 2:7
File "<stdin>", line 1
y = 2:7
^
SyntaxError: invalid syntax
>>> a = array([1,2,3,4])
>>> b = array([5,6,7,8])
>>> c = arange(1, 5, 0.1)
>>> c
array([ 1. , 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2. ,
2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3. , 3.1,
3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4. , 4.1, 4.2,
4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9])
>>> d = linspace(1,5,10)
>>> d
array([ 1. , 1.44444444, 1.88888889, 2.33333333, 2.77777778,
3.22222222, 3.66666667, 4.11111111, 4.55555556, 5. ])
>>> e = logspace(1, 100, num=10)
>>> e
array([ 1.00000000e+001, 1.00000000e+012, 1.00000000e+023,
1.00000000e+034, 1.00000000e+045, 1.00000000e+056,
1.00000000e+067, 1.00000000e+078, 1.00000000e+089,
1.00000000e+100])
>>> add(a,b)
array([ 6, 8, 10, 12])
>>> mean(a)
2.5
>>> mean(b)
6.5
>>> x=array([1,2,3,4])
>>> sub(a,b)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sub' is not defined
>>> substract(a,b)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'substract' is not defined
>>> subtract(a,b)
array([-4, -4, -4, -4])
>>> multiply(a,b)
array([ 5, 12, 21, 32])
>>> divide(a,b)
array([0, 0, 0, 0])
>>> divide(b,a)
array([5, 3, 2, 2])
>>> true_divide(b,a)
array([ 5. , 3. , 2.33333333, 2. ])
>>>
Post preview:
Close preview