Q:

Write a NumPy program to extract first, third and fifth elements of the third and fifth rows from a given (6x6) array

0

Write a NumPy program to extract first, third and fifth elements of the third and fifth rows from a given (6x6) array.

All Answers

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

import numpy as np
arra_data = np.arange(0,36).reshape((6, 6))
print("Original array:")
print(arra_data)
print("\nExtracted data: First, third and fifth elements of the third and fifth rows")
print(arra_data[2::2, ::2]) 

Sample Output:

Original array:
[[ 0  1  2  3  4  5]
 [ 6  7  8  9 10 11]
 [12 13 14 15 16 17]
 [18 19 20 21 22 23]
 [24 25 26 27 28 29]
 [30 31 32 33 34 35]]

Extracted data: First, third and fifth elements of the third and fifth rows
[[12 14 16]
 [24 26 28]]

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