Applications Closing for Certification Course on Artificial Intelligence and Deep Learning by IIT Roorkee | Closing in

  Apply Now

Numpy - Mathematical Operations on NumPy Arrays - Conditional Operators

Conditional operators (like <, >, etc.) are also applied element-wise.


import numpy as np
m = np.array( [ 20, -5, 30, 40] )

m < [15, 16, 35, 36]

Output will be

array([ False, True, True, False], dtype=bool)

Now let us check for another condition

m< 25

Output will be

array( [ True, True, False, False], dtype=bool )

To get the elements below a value of 25, you can use the below syntax


Output will be

 array( [20, -5 ] )

Please follow the below steps:

(1) Please import the required libraries

import numpy as np

(2) Please create a NumPy array called U, as shown below

U = np.array([ [ 22, 45], [90, 4 ] ] )

(3) Get all the elements of U which are less than 45, and print the result using the print() function

print( << your code comes here>> )

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...