``````

In [1]:

import numpy as np

``````
``````

In [2]:

a = np.zeros((3, 3), np.int)
print(a)

``````
``````

[[0 0 0]
[0 0 0]
[0 0 0]]

``````
``````

In [3]:

print(a.shape)

``````
``````

(3, 3)

``````
``````

In [4]:

b = np.arange(3)
print(b)

``````
``````

[0 1 2]

``````
``````

In [5]:

print(b.shape)

``````
``````

(3,)

``````
``````

In [6]:

print(a + b)

``````
``````

[[0 1 2]
[0 1 2]
[0 1 2]]

``````
``````

In [7]:

b_1_3 = b.reshape(1, 3)
print(b_1_3)

``````
``````

[[0 1 2]]

``````
``````

In [8]:

print(b_1_3.shape)

``````
``````

(1, 3)

``````
``````

In [9]:

print(np.tile(b_1_3, (3, 1)))

``````
``````

[[0 1 2]
[0 1 2]
[0 1 2]]

``````
``````

In [10]:

b_3_1 = b.reshape(3, 1)
print(b_3_1)

``````
``````

[[0]
[1]
[2]]

``````
``````

In [11]:

print(b_3_1.shape)

``````
``````

(3, 1)

``````
``````

In [12]:

print(a + b_3_1)

``````
``````

[[0 0 0]
[1 1 1]
[2 2 2]]

``````
``````

In [13]:

print(np.tile(b_3_1, (1, 3)))

``````
``````

[[0 0 0]
[1 1 1]
[2 2 2]]

``````
``````

In [14]:

print(b_1_3)

``````
``````

[[0 1 2]]

``````
``````

In [15]:

print(b_1_3.shape)

``````
``````

(1, 3)

``````
``````

In [16]:

print(b_3_1)

``````
``````

[[0]
[1]
[2]]

``````
``````

In [17]:

print(b_3_1.shape)

``````
``````

(3, 1)

``````
``````

In [18]:

print(b_1_3 + b_3_1)

``````
``````

[[0 1 2]
[1 2 3]
[2 3 4]]

``````
``````

In [19]:

print(np.tile(b_1_3, (3, 1)))

``````
``````

[[0 1 2]
[0 1 2]
[0 1 2]]

``````
``````

In [20]:

print(np.tile(b_3_1, (1, 3)))

``````
``````

[[0 0 0]
[1 1 1]
[2 2 2]]

``````
``````

In [21]:

print(np.tile(b_1_3, (3, 1)) + np.tile(b_3_1, (1, 3)))

``````
``````

[[0 1 2]
[1 2 3]
[2 3 4]]

``````
``````

In [22]:

c = np.arange(4)
print(c)

``````
``````

[0 1 2 3]

``````
``````

In [23]:

print(c.shape)

``````
``````

(4,)

``````
``````

In [24]:

print(b_3_1)

``````
``````

[[0]
[1]
[2]]

``````
``````

In [25]:

print(b_3_1.shape)

``````
``````

(3, 1)

``````
``````

In [26]:

print(c + b_3_1)

``````
``````

[[0 1 2 3]
[1 2 3 4]
[2 3 4 5]]

``````
``````

In [27]:

print(np.tile(c.reshape(1, 4), (3, 1)))

``````
``````

[[0 1 2 3]
[0 1 2 3]
[0 1 2 3]]

``````
``````

In [28]:

print(np.tile(b_3_1, (1, 4)))

``````
``````

[[0 0 0 0]
[1 1 1 1]
[2 2 2 2]]

``````
``````

In [29]:

print(np.tile(c.reshape(1, 4), (3, 1)) + np.tile(b_3_1, (1, 4)))

``````
``````

[[0 1 2 3]
[1 2 3 4]
[2 3 4 5]]

``````