Q:

Write a NumPy program to swap rows and columns of a given array in reverse order

0

Write a NumPy program to swap rows and columns of a given array in reverse order

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
nums = np.array([[[1, 2, 3, 4],
               [0, 1, 3, 4],
               [90, 91, 93, 94],
               [5, 0, 3, 2]]])
print("Original array:")
print(nums)
print("\nSwap rows and columns of the said array in reverse order:")
new_nums = print(nums[::-1, ::-1])
print(new_nums)

Sample Output:

Original array:
[[[ 1  2  3  4]
  [ 0  1  3  4]
  [90 91 93 94]
  [ 5  0  3  2]]]

Swap rows and columns of the said array in reverse order:
[[[ 5  0  3  2]
  [90 91 93 94]
  [ 0  1  3  4]
  [ 1  2  3  4]]]
None

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now