Exercise 2
Write a python program using the numpy library that determines the transpose of the following matrix:
A = numpy.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9,]])
Solution
import numpy as np
A = np.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9,]])
t_A = A.T
print("The transopse of A is: n", t_A)
# the output is:
"""
The transopse of A is:
[[1 4 7]
[2 5 8]
[3 6 9]]
"""
Younes Derfoufi
my-courses.net
my-courses.net