Slicing

Report a typo

Write a code that extracts a part of the following array. The first integer in the input is a step for extracting a subarray, the second integer is a step for rows in the subarray, and the last integer is an index for the elements in the rows. Print the resultant array.

a = np.array([[[10, 11, 12], [13, 14, 15], [16, 17, 18]],
              [[20, 21, 22], [23, 24, 25], [26, 27, 28]],
              [[30, 31, 32], [33, 34, 35], [36, 37, 38]],
              [[40, 41, 42], [43, 44, 45], [46, 47, 48]],
              [[50, 51, 52], [53, 54, 55], [56, 57, 58]],
              [[60, 61, 62], [63, 64, 65], [66, 67, 68]],
              [[70, 71, 62], [73, 74, 65], [76, 77, 78]],
              [[80, 81, 62], [83, 84, 85], [86, 87, 88]]])

Sample Input 1:

2
2
1

Sample Output 1:

[[11 17]
 [31 37]
 [51 57]
 [71 77]]
Write a program in Python 3
import numpy as np


a = np.array([[[10, 11, 12], [13, 14, 15], [16, 17, 18]],
[[20, 21, 22], [23, 24, 25], [26, 27, 28]],
[[30, 31, 32], [33, 34, 35], [36, 37, 38]],
[[40, 41, 42], [43, 44, 45], [46, 47, 48]],
[[50, 51, 52], [53, 54, 55], [56, 57, 58]],
[[60, 61, 62], [63, 64, 65], [66, 67, 68]],
[[70, 71, 62], [73, 74, 65], [76, 77, 78]],
[[80, 81, 62], [83, 84, 85], [86, 87, 88]]])
# your code here
___

Create a free account to access the full topic