In [1]:
import numpy as np
In [2]:
x = np.arange(10)
y = np.arange(10)
In [3]:
x + y
Out[3]:
In [4]:
x + 6
Out[4]:
In [5]:
x = np.arange(12).reshape(3,4)
y = 2*np.arange(12).reshape(3,4)
In [6]:
x + y
Out[6]:
In [7]:
x.shape
Out[7]:
In [8]:
y.shape
Out[8]:
In [9]:
x
Out[9]:
In [14]:
z = np.arange(4)
z
Out[14]:
In [15]:
x + z
Out[15]:
In [16]:
x.shape, z.shape
Out[16]:
In [17]:
z2 = np.arange(3)
z2
Out[17]:
In [18]:
x + z2
In [19]:
x + z2[:, np.newaxis]
Out[19]:
In [21]:
x + z2[:, None]
Out[21]:
In [31]:
x + z2[None, :]
In [33]:
z2[None, :].shape
Out[33]:
In [22]:
z2.shape
Out[22]:
In [24]:
print(z2[:, None])
In [28]:
x.shape
Out[28]:
In [30]:
z2[:, None, None].shape
Out[30]:
In [35]:
import os
In [36]:
os.environ['DROPBOX']
Out[36]:
In [37]:
os.environ['PATH']
Out[37]:
In [39]:
os.environ['ROBOAODIR'] + '/my/datafile'
Out[39]:
More strings!
In [40]:
for x in range(10):
print(x)
In [44]:
for x in 'abcdefgh':
print(x)
In [49]:
x = 3; y = 4.12512
In [52]:
'x is {0:.3f}, y is {1:.1f}!'.format(x, y)
Out[52]:
In [53]:
l = [1,3,5,7,9]
'index 2 of l is {0[2]}, index 4 is {0[4]}'.format(l)
Out[53]:
In [55]:
d = dict(a=2, b=3)
'check out this value: {0[a]}'.format(d)
Out[55]:
In [60]:
import re
s = 'abcb124cde'
m = re.search('b\d+', s)
if m:
print('yes!')
In [61]:
m.group(0)
Out[61]:
In [64]:
s = 'okj?okl,'
m = re.search('\w+', s)
m.group(0)
Out[64]:
In [ ]: