Skip to content
Justice Tech School

tile and repeat

repeat repeats elements and tile repeats the whole array.

Example
a = np.array([1, 2])
print(np.repeat(a, 3))
print(np.tile(a, 3))
print(np.tile(a, (2, 2)))

Result

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

Exercise

Repeat the block.

np.(a, 3)

Quiz Test

What does repeat do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.