Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Last answered:

28 Dec 2022

Posted on:

12 Nov 2022

0

Made a code that the output is confusing

matrix_B = np.array([[1,2,3,4,5], [2,7,5,2,9], [12,13,7,6,8]])
matrix_B



Here is the code ---> matrix_B[matrix_B[:,:] % 2 == 0] | matrix_B[matrix_B[:,:] >5] #i don't understand this code...
below is the output

array([ 7, 13, 14, 15, 15,  6,  8], dtype=int32)
3 answers ( 0 marked as helpful)
Instructor
Posted on:

16 Nov 2022

0

Hi Arowesegbe,
thanks for reaching out! In order to create a condition where the output is an array containing even numbers or numbers greater than 5, you need the following syntax:

matrix_B[(matrix_B[:,:] % 2 == 0) | (matrix_B[:,:] >5)]

Hope this helps!

Best,
365 Eli

Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Posted on:

16 Nov 2022

0

Thank you very much. it works

Posted on:

28 Dec 2022

1

Don't forget the parentheses!

Submit an answer