Exercise 1

Using the numpy library, create a 3x3 type matrix made up of the integers 1, 2, 3, ..., 9.

Solution

import numpy as np
M = np.arange(1 , 10).reshape((3, 3))
print(M)
# attach:
"""
[[1 2 3]
[4 5 6]
[7 8 9]]
"""

Younes Derfoufi
my-courses.net

Leave a Reply