Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get desired output from 5 x 5 matrix | Numpy |

I am solving a below question where i want to print the expected output from 5 x 5 matrix

5 x 5 matrix

0,  1,  3,   3,  4 
11,  6, 54,  8,  9 
12, 11, 10, 18,  4 
17, 16, 19, 10,  1 
21, 21, 52, 33, 22 

Expected output :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

12 10
21 52

I tried this not able to apply logic

arr[2:,:3:2]

>Solution :

Seems like you got some assignment work

Below code might work for you just try it

import numpy as np

arr=np.array([
[0,  1,  3,   3,  4 ],
[11,  6, 54,  8,  9 ],
[12, 11, 10, 18,  4 ],
[17, 16, 19, 10,  1 ],
[21, 21, 52, 33, 22 ] ] )

arr[2:,:3:2][::2]

Expected output :

array([[12, 10],
       [21, 52]])

Note : The code is tested on Google Collab

Incase found any issue feel free to edit it

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading