Exercise 8

Generate a numpy matrix by repeating a smaller 2-dimensional, 5 times.

Solution

import numpy as np

A = np.array([[5 , 7],
[3 , 9]])

C = np.tile(A , 5)

print(C)
"""
attach:
[[5 7 5 7 5 7 5 7 5 7]
[3 9 3 9 3 9 3 9 3 9]]
"""

Younes Derfoufi
my-courses.net

Leave a Reply